E
effbiae
is sscanf meant not to consume chars? run this program:
/*ss.c*/
int main(int argc,char *argv[])
{char buf[3];
int i;for(i=0;i<3;i++)
{printf("ss: %d %s\n",sscanf(argv[1],"%2s",buf),buf);
printf(" s: %d %s\n",scanf("%2s",buf),buf);
}}
with the command:
$ gcc ss.c && echo 1234567890 |./a.out 1234567890
ss: 1 12
s: 1 12
ss: 1 12
s: 1 34
ss: 1 12
s: 1 56
note that the progress of ss differs to that of s.
kind regards,
jack
/*ss.c*/
int main(int argc,char *argv[])
{char buf[3];
int i;for(i=0;i<3;i++)
{printf("ss: %d %s\n",sscanf(argv[1],"%2s",buf),buf);
printf(" s: %d %s\n",scanf("%2s",buf),buf);
}}
with the command:
$ gcc ss.c && echo 1234567890 |./a.out 1234567890
ss: 1 12
s: 1 12
ss: 1 12
s: 1 34
ss: 1 12
s: 1 56
note that the progress of ss differs to that of s.
kind regards,
jack