P
Phil Scadden
Couldnt submit this to MS without paying $$$ but here is a bug with C++.
This tiny snippet reads from a file containing a single DOUBLE
#include<stdio.h>
int main()
{
double output;
FILE *test_out;
test_out = fopen("test.out","r");
fread (&(output),sizeof(double),1,test_out);
fclose(test_out);
printf("Output: %e\n", output);
}
Problem is that output is wrong - should be 4890.695 but get rubbish
instead. It is a different no. to what
was written with fwrite. The bizarre thing is that for most numbers it works
fine but this one (and others),
I get rubbish. If I compile exactly the same code with other C compilers on
the same machine, they read the
file correctly. I infer this is BUG in MS C++.
Attached is file with the code and the 8 byte input file if anyone wants to
confirm this.
This tiny snippet reads from a file containing a single DOUBLE
#include<stdio.h>
int main()
{
double output;
FILE *test_out;
test_out = fopen("test.out","r");
fread (&(output),sizeof(double),1,test_out);
fclose(test_out);
printf("Output: %e\n", output);
}
Problem is that output is wrong - should be 4890.695 but get rubbish
instead. It is a different no. to what
was written with fwrite. The bizarre thing is that for most numbers it works
fine but this one (and others),
I get rubbish. If I compile exactly the same code with other C compilers on
the same machine, they read the
file correctly. I infer this is BUG in MS C++.
Attached is file with the code and the 8 byte input file if anyone wants to
confirm this.