www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/30/12:56:54

Message-Id: <1.5.4b13.32.19960330161917.0066a64c@oak-web.washington-ch.oh.us>
Mime-Version: 1.0
Date: Sat, 30 Mar 1996 11:19:17 -0500
To: pierre AT Eng DOT Sun DOT COM
From: Daniel Pierce <ab134 AT oak-web DOT washington-ch DOT oh DOT us>
Subject: Re: bug sscanf when match fails ?
Cc: djgpp AT delorie DOT com

I too have found the sscanf bug and have had to use this instead:

        sscanf(" %s %s %s ",a1, a2, a3, a4);
        strcpy(words,a1);
        Bdata = atof(a2);
        Cdata = atoi(a3);
        Ddata = atol(a4);

A real kludge if you as me :(.




At 02:52 PM 3/29/96 -0800, you wrote:
>
>It seems that sscanf does not stop parsing when a match fails (as it
>should). The following shows the bug. This has been tested on v1, but
>someone told me it was the same with v2.
>
>Regards
>Pierre Willard
>
>
>#include <stdio.h>
>
>main()
>{
>    char *test_str = "demo PPL_ID 10";    
>    char app_name[40], expstr[20];
>    int match;
>    int app_id;
>    app_name[0]=0;
>	expstr[0]=0;
>
>    match = sscanf(test_str, "%s %d %s", 
>                  app_name, &app_id, expstr);
>    printf("match = %d, app_name = \"%s\", app_id = %d, expstr = \"%s\"\n",
>            match, app_name, app_id, expstr);
>}
>
>/*
>Result on Solaris (correct):
>============================
>
>match = 1, app_name = "demo", app_id = 0, expstr = ""
>
>
>Result on DJGPP (incorrect)
>========================
>
>match = 2, app_name = "demo", app_id = 0, expstr = "PPL_ID"
>
>
>*/
>
>

- Raw text -


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