The output in bold shows a line from the file then what has supposedly been put into the structure. At line 193 something goes wrong.
Code:
/
typedefstruct sauce
{
char date[7];
float sauce;
int index;
} _sauce;
_sauce* open_and_read(char * filename)
{
FILE *fp;
_sauce *input;
int i;
char line[200];
input = (_sauce*)calloc(days_of_data, sizeof(*input));
if ((fp = fopen(filename, "r")) == NULL)
{
printf("Couldn't open %s\n", filename);
exit(0);
};
for(i = 0; i < days_of_data; i++)
{
fgets(line, 200,fp);
printf("%s",line);
strcpy(input[I].date,strtok(line,","));
input[I].sauce = atof(strtok(NULL,","));
input[I].index = i;
printf("%d %s %f\n", input[I].index, input[I].date, input[I].sauce);
}
return input;
};
[B]10/5/99,113.319[/B]
[B]189 10/5/99 113.319000[/B]
[B]10/6/99,112.7414[/B]
[B]190 10/6/99 112.741402[/B]
[B]10/7/99,112.5105[/B]
[B]191 10/7/99 112.510498[/B]
[B]10/8/99,110.7106[/B]
[B]192 10/8/99 110.710602[/B]
[B]10/11/99,111.0172[/B]
[B]193 10/11/99\316\336B\301 111.017197[/B]
[B]10/12/99,112.4442[/B]
[B]194 10/12/99n\343\340B\302 112.444199[/B]
/[code]
[/I][/I][/I][/I][/I][/I]