Hello. I have been kicking myself for a while now and I was wondering if anyone could please help me. My code is:
char fname[FNAME_LEN] = "blah"
FILE * fp = fopen(fname, "r");
char line[BUF_LEN];
while( fscanf(fp, "%s", line) != EOF )
{
double x = atof(strtok(line, "|") );
unsigned long y = atol(strtok(NULL, "\0"));
printf("%f - %d\n", x, y);
}
fclose(fp)
my input stream format is:
123.45|12345
for every x value, the program prints -0.00000 but all the y values print correctly. Also, if I don't use atof and just print x as a string, I get the correct output.
Any help would be greatly appreciated.