delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/08/08/03:04:35

X-Sybari-Space: 00000000 00000000 00000000 00000000
From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
Message-Id: <200308080701.JAA17576@lws256.lu.erisoft.se>
Subject: Re: (fwd) Re: sscanf's return value
To: djgpp-workers AT delorie DOT com
Date: Fri, 8 Aug 2003 09:01:31 +0200 (MET DST)
In-Reply-To: <200308071532.RAA17010@lws256.lu.erisoft.se> from "Martin Stromberg" at Aug 07, 2003 05:32:34 PM
X-Mailer: ELM [version 2.5 PL3]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019