I have written a program to read strings from a text file. The text file is very brief and the fscanf functions seem to be reading the blank parts of the file as some type of junk characters when I look in the variables inspector in the debug mode. The characters are like Í. So Visual C++ produces an Access Violation when the fscanf statements get past the text in the file. How do I avoid this? Any help would be appreciated.
You maybe mis-interpreting the what you see.
Those funny characters are not put there by the fscanf function, they
are set deliberately by Visual C++.
In debugging mode - Microsoft Visual C++ tracks uninitialsed variables.
and it uses this funny character Í to show that. (actuall decimal value 204)
If you are looking at the file pointer in the variables window, you should see the actual data of the file
followed by these characters. These are the rubbish beyond the End Of File mark and therefore will not be read by fscanf.
If you see these characters in a variable in the debug window it means that the variable is uninitialised.
Í = 204 decimal = CC hex - so VisualC++ will set an unitialised integer to 0xCCCC
You may also see 0xCD used.