Mail Archives: djgpp-workers/2003/08/08/03:04:35
> From: Dan DOT Pop AT cern DOT ch (Dan Pop)
> Newsgroups: comp.std.c
> Subject: Re: sscanf's return value
> Date: 4 Aug 2003 12:02:18 GMT
> Message-ID: <bgli0a$qi8$2 AT sunnews DOT cern DOT ch>
>
> In <Pine DOT LNX DOT 4 DOT 55L-032 DOT 0307312225220 DOT 25522 AT unix46 DOT andrew DOT cmu DOT edu> "Arthur J. O'Dwyer" <ajo AT andrew DOT cmu DOT edu> writes:
>
>
> >On Thu, 31 Jul 2003, Stefan Farfeleder wrote:
> >>
> >> Arthur J. O'Dwyer wrote:
> >> > On Thu, 31 Jul 2003, Bruce Wheeler wrote:
> >> >> On 31 Jul 2003 11:17:13 GMT, Dan DOT Pop AT cern DOT ch (Dan Pop) wrote:
> >> >> >
> >> >> > #include <stdio.h>
> >> >> >
> >> >> > int main()
> >> >> > {
> >> >> > int rc = sscanf("123", "%*[0123456789]%*c");
> >> >> > printf("%d\n", rc);
> >> >> > return 0;
> >> >> > }
> >>
> >> > gcc, presumably the compiler Dan used too, reports -1 and 1.
...
> >Thanks for the correction. I must have been extra clueless today,
> >because I see DJGPP produces the right answers (0 and 1) - which
> >means I must've only tested the code on the Linux implementation.
> >... I wonder how one would go about rectifying such a thing...
>
> OTOH, DJGPP will output 0 even if the input string is "" in the code
> quoted above. So, DJGPP's sscanf is broken, too, just in a different
> way :-)
The second return value they are talking about is when the code is
changed to
#include <stdio.h>
int main()
{
char buff[4];
int rc = sscanf("123", "%[0123456789]%*c", buff);
printf("%d\n", rc);
return 0;
}
Right,
MartinS
- Raw text -