Saturday, March 20, 2010

fscanf hates doubles

When you want to read floating point data with the fscanf function, remember that the type must be float i.e. you cannot use double. Here is an example demonstrating what happens when you use double:


Koray Kucuk said...

You have to use long modifier to read and assign double variables from file or console. i.e. 'fscanf(file,"%lf",&x);'

Samil Korkmaz said...

Grazie mille :)