how can to this loop to take one character at a time ?
thanks for your answer in advance
Printable View
how can to this loop to take one character at a time ?
thanks for your answer in advance
That's so vague. It's like asking about putting fluid in a car.
What fluid? Where are you trying to put it? What are you trying to accomplish?
For your particular question, this is a guess: if you're trying to read a char from a file, char per char, you can use fgetc() in a loop.
Code:int c;
while((c = fgetc(stdin)) != EOF)
{
// c has the char... do what you want with it
}
sorry i didn't post the loop
for(ch=getc(inp); ch!=EOF; ch=getc(inp))
Why not condense it?
Code:while((ch = getc(inp)) != EOF)
{
/* Code here */
}
Naturally 'ch' needs to be an integer if you're testing against EOF.
Quzah.