Hi all,
I wrote a program in linux which parsed the headers of some data files I have. Now, I've tried to port it to windows, and everything seems to work except I can't seem to actually read the data! The data is in ASCII format, very simple text files. Why is this failing? This is my code:
Code:
int parseFile (char fileName[100], FILE *out)
{
int loc=1; //loc is the location of the curser in the string
char dat[200];
char str[RESULT_LENGTH];
FILE *inp;
inp = fopen(fileName, "r");
if (inp==NULL)
{
printf("Could not open %s for reading.\n", fileName);
return 0;
}
//get 'arg'th line of data and parse it into data.csv
fgets(dat, sizeof(dat), inp);
loc=loc+getinp(str,'\'',dat,loc);
fprintf(out, "%s,", str); //print filename
loc=loc+getinp(str,'\'',dat,loc); //search to date
loc=loc+getinp(str,'\'',dat,loc); //print date
fprintf(out, "%s,", str);
...
it goes on for a while like that, but why does it suddenly not work?
If I instead just use fgets and then print the resulting string, I get ASCII garbage. . .
Thanks a bunch,
Dave