Mail Archives: djgpp/1996/03/30/12:56:54
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 -