B
BlueJ
Hi,
I run the following source code:
#include <stdio.h>
main()
{
int i;
unsigned int j;
char input[] = "10 0x1b aaaaaaaa bbbbbbb";
char s[5];
sscanf(input, "%d %x %5[a-z] %*s %f ", &i, &j, s, s);
printf("%d %d %s\n", i, j, s);
}
And it prints out: 10 27 aaaaa
What I understand is sscan puts something into s twice. the first
time, s = "aaaaa". afterwards, sscanf put some floating number to s.
So when printf, s should be not aaaa.
can anybody help to explain?
I run the following source code:
#include <stdio.h>
main()
{
int i;
unsigned int j;
char input[] = "10 0x1b aaaaaaaa bbbbbbb";
char s[5];
sscanf(input, "%d %x %5[a-z] %*s %f ", &i, &j, s, s);
printf("%d %d %s\n", i, j, s);
}
And it prints out: 10 27 aaaaa
What I understand is sscan puts something into s twice. the first
time, s = "aaaaa". afterwards, sscanf put some floating number to s.
So when printf, s should be not aaaa.
can anybody help to explain?