As David Given mentioned earlier, you don’t need to pre-process the file. strtof () and strtod () can convert a NaN string to a float / double NaN value.
If you want to replace the values with 0.0 in your dataset, you can do this using the isnan () function.
if (isnan(val))
{
val = 0.0;
}