X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <41373f54$0$175$cc7c7865@news.luth.se> From: Martin Str|mberg Subject: Re: scanf: strange behavior? Newsgroups: comp.os.msdos.djgpp References: <20040902144152 DOT GH6858 AT webhome DOT cz> User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (NetBSD/1.6Q (alpha)) Date: 02 Sep 2004 15:42:12 GMT Lines: 36 NNTP-Posting-Host: speedy.ludd.ltu.se X-Trace: 1094139732 news.luth.se 175 130.240.16.13 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Egon Eckert wrote: > compiling and running this code: > #include > int main(int, const char**) > { > char c[2]; > printf("%d\n", sscanf("A", "%c%c", c, c + 1)); > return 0; > } > gives: > 1 in GNU libc (on Linux) > 1 in Borland C++ 3.1 (on DOS) > -1 in djgpp > It's conformant with the docs: "If input ends, or if there is any > input failure before the first item is converted and assigned, `EOF' > is returned.", so it's not to be called a 'bug', but... > Do you think it's a standard violation, or just a "difference", > ie. behavior not specified by POSIX, ANSI or other (involved) > authority? It's a standard(1) violation in GNU libc and Borland C++ 3.1 (if your report is accurate). 1. C99 (at least). Right, MartinS