I got a Problem with my strtod()
it seems to add some digits. I'm reading
2\t5241021356985.0302\t9.09\t825.45
from a File And after skipping the integer 2
I get the following output
output: 5241021356985.030273 9 .090000
Here is my Code
char *input_string = (char*) calloc(filesize, sizeof (char*));
char *output_string = (char*) calloc(filesize, sizeof (char*));
char *input_end;
fgets(input_string, filesize, infile);
input_end = input_string;
int size_to_read = (int) strtof(input_string, &input_end);
char *temp_string=(char*)calloc(70,sizeof(char*)); // max double value
double temp = 0;
++input_string;
for (int i = 0; i < size_to_read; ++i) {
temp = strtod(input_string, &input_end);
sprintf(temp_string, "%lf\t", temp);
strcat(output_string, temp_string);
input_string = input_end;
++input_string;
}
strcat(output_string, "\0");
printf("output: %s\n", output_string);