EOF type not recognized using '!=' ?
Posted: Sun Aug 12, 2012 3:27 pm
hello,
I don't know if its an inherent problem of gcc, devkitarm or only my lack of knowledge, so if someone could explain me the following thing:
I wrote this function
But the loop won't end if EOF is reached, after some tests, I figured that fc!=EOF is always equivalent to true, i had to cast fc to make it work properly
This problem doesn't happen with == because this code works fine :
Thanks!
I don't know if its an inherent problem of gcc, devkitarm or only my lack of knowledge, so if someone could explain me the following thing:
I wrote this function
Code: Select all
inline char fFindC(FILE* file,char c)
{
char fc=EOF;
do
{
fc=fgetc(file);
}
while(fc!=EOF || fc!=c);
return c;
}
Code: Select all
(s8)fc != EOF
Code: Select all
inline char fFindC(FILE* file,char c)
{
char fc=EOF;
do
{
fc=fgetc(file);
}
while(!(fc==EOF || fc==c));
return c;
}