Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!puddle!p0.f4.n494.z5.fidonet.org!cspw.rures From: cspw.rures@p0.f4.n494.z5.fidonet.org (cspw rures) Newsgroups: comp.lang.c Subject: ungetc/scanf independent? Message-ID: <3009.260C8D7C@puddle.fidonet.org> Date: 25 Mar 90 18:03:46 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 5:494/4.0 - Settler City Fido, Grahamstown RSA Lines: 32 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 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@p0.f4.n494.z5.fidonet.org