[SOLVED] File reading goes one past EOF

Hi guys. I'm having a bit of problem with my code. Here it is.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
fManA = fopen("Settings", "r");
int varNum = 1;
int retStat;
	
while(retStat != EOF){
		
	rawData = getc(fManA);
	printf("DEBUG: %c\n", rawData);
	retStat = rawData;
		
}
	
fclose(fManA);
exit(0);


The reason why I didn't just put the getc command in the while loop is because I also need to store variables later. (I should be able to figure out that part.) Anyways, the Settings file contains:

 
0,0


With no linebreak or anything. But when I used debugging output, I got:

1
2
3
4
DEBUG: 0
DEBUG: ,
DEBUG: 0
DEBUG: (Unknown question mark symbol)


Any help? Thank you. c:
Last edited on
Maybe rearrange the code a bit:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    FILE * fManA = fopen("Settings", "r");
    
    int varNum = 1;
    
    int rawData = getc(fManA);
    int retStat = rawData;
    
    while (retStat != EOF) {
        printf("DEBUG: %c\n", rawData);
        rawData = getc(fManA);
        retStat = rawData;
    }
    
    fclose(fManA);
Thanks a bunch! ^^ You helped a lot. Now I may proceed... Cx Again, thanks.
Topic archived. No new replies allowed.