ungetc/scanf independent?

cspw rures cspw.rures at p0.f4.n494.z5.fidonet.org
Mon Mar 26 04:03:46 AEST 1990


 
I have a VAX problem when interleaving calls to getc and ungetc with
calls to scanf.   On all the compilers I tested (except the VAX VMS 4.2),
and "ungetc" character is available to a subsequent scanf.  On the VAX
it appears that getc and ungetc have their own private "view" of the file,
not shared by scanf.
 
Is the VAX C compiler broken?   What does ANSI say?
 
     #include <stdio.h>
 
     int main(void)
     {  char c; int i;
        c = getc(stdin);
        ungetc(c,stdin);
        scanf("%d",&i);
        printf("%d\n",i);
     }
 
For test data like
123
the VAX prints 23.
 
Thanks
Pete Wentworth



--  
uucp: uunet!m2xenix!puddle!5!494!4.0!cspw.rures
Internet: cspw.rures at p0.f4.n494.z5.fidonet.org



More information about the Comp.lang.c mailing list