Mail Archives: djgpp/1996/03/29/18:03:43
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 -