So, I have the following code (C):
char c = getc(in);
if (c == '(')
...
if (c == '%')
...
if (isdigit(c))
{
int n;
ungetc(c, in);
scanf("%i", &n);
...
}
Everything is fine and dandy, when I read the input from stdin, but reading the input from the file, the call scanfdoes not end.
I added code around the call to find out what happens before the call scanf. One such example is
c = '0'- the character immediately after
cis equal)
Is there a buffer after ungetcor something else? What can happen that it works fine when input stdin, but not when its file? (I am not familiar with IO in C).
edit: Should be used fscanf... boy - my face is red.
source
share