Xref: utzoo comp.std.c:3353 comp.lang.c:30166 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!mason From: mason@tc.fluke.COM (Nick Mason) Newsgroups: comp.std.c,comp.lang.c Subject: Explain this sscanf behavior. Keywords: sscanf ANSI Message-ID: <1990Jul6.181830.2549@tc.fluke.COM> Date: 6 Jul 90 18:18:30 GMT Organization: John Fluke Mfg. Co., Inc., Everett, WA Lines: 54 What should sscanf do with the following? Does anyone have the ANSI standard and shed some light on the following? I would like "hard" replies, not "I think it should ....". Thanks in advance. Given: char *buf="123"; char *str="123x"; int a, b, x; b = -99; x = sscanf(str, "%d%n", &a, &b); printf("x=%d, a=%d, b=%d\n",x,a,b); x = sscanf(buf, "%d%n", &a, &b); printf("x=%d, a=%d, b=%d\n",x,a,b); What is the CORRECT output according to the standard??? I tried this with 3 different compilers and got the following: compiler A: x=1 a=123 b=3 x=1 a=123 b=3 compiler B: x=1 a=123 b=3 x=1 a=123 b=4 <-- yes 4. compiler C: x=1 a=123 b=3 x=1 a=123 b= -99 I'm confused????!!!!! Compiler C is "100% ANSI compatible".???? Nick.