The first bug that leaps out as I look at the code:
Originally Posted by Manju Lata Joshi
The input you quoted has no ',' in it, so the above loop would read the rest of the file, then read EOF over and over again, until it has exceeded the allocated size of pos far enough to cause an access violation.
If there was a ',' and the outer loop worked, then the fact that the input file doesn't end exactly on a ',' could make the previous inner loop overwrite word.
Also, are you taking newlines into account when reading the input?
my output file is also a text file and totally blank:
File output is buffered, so even if there was a ',' in the input and the code went past the printf (which should have been fprintf) the access violation would still stop the buffered output from reaching the file.