Sorry to make this a new thread, but I decided my old post was incredibly poorly worded..
So, when I try to use fprintf, the program fails to write to the file (the file becomes "unreadable").
here is the offending code:
Code:
out = fopen(inputFile, "w");
if (out==NULL)
{
printf("Could not open %s for reading.\n", inputFile);
mypause();
return 0;
}
//get 'arg'th line of data and parse it into data.csv
loc = 1;
myfgets(dat, sizeof(dat), inp);
loc=loc+getinp(str,'\'',dat,loc);
/*printf(">>>%s<<<", str);
mypause();
exit(0);*/
fprintf(out, "%s,", str); //print filename
So, to debug, I added the commented section, and re-ran the program. However, this part works just fine (the string is printed correctly).
I also tried putting
Code:
fprintf(out, "hello world\n");
mypause();
exit(0);
directly after opening the file, which is also successful.
So why does the program fail as is? This isn't a homework assignment or anything, I just have about 300 of these files to combine into one CSV file, and I thought this method would be faster/more instructive that doing it by hand.
Thanks!