c - Parsing a text file - any reason why space / new line would be ignored? -


i have while loop...

char count[3] = {0}; int = 0;  while( c != ' ' || c != '\n' || c != '\t' ) {     count[i] = c;     c = fgetc(fp);     i++;     } 

and though see while debugging space , newline right ascii numbers, while loop not exit. know causing this?

the logic in conditional not right. evaluate true time.

while( c != ' ' || c != '\n' || c != '\t' ) 

if c equal ' ' not equal '\n' or '\t'.

what need is:

while( c != ' ' && c != '\n' && c != '\t' ) 

and measure, add c != eof.

while( c != ' ' && c != '\n' && c != '\t' && c != eof ) 

it might simpler use:

while( !isspace(c) && c != eof ) 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -