J
jacob navia
Consider this program:
// ScanTest.c
#include <stdio.h>
int main(int argc, char* argv[])
{
int x1, x2, x3;
char s[16] = "38 02 14";
char t[16] = "38 08 14";
sscanf( t, "%i %i %i", &x1, &x2, &x3 );
printf( "x1 = %i, x2 = %i, x3 = %i\n", x1, x2, x3 );
sscanf( s, "%i %i %i", &x1, &x2, &x3 );
printf( "x1 = %i, x2 = %i, x3 = %i\n", x1, x2, x3 );
return 0;
}
The output using lcc-win32 sscanf is:
x1 = 38, x2 = 8, x3 = 14
x1 = 38, x2 = 2, x3 = 14
The output with gcc (under linux) or with Microsoft VC6++ is:
x1 = 38, x2 = 0, x3 = 8
x1 = 38, x2 = 2, x3 = 14
I can see why this should be. Can anyone here explain?
Thanks for your time
P.S. I have verified that there is no uppercase "O" that replaces
a zero. The "08" is well zero and then eight.
Why does it stop???
// ScanTest.c
#include <stdio.h>
int main(int argc, char* argv[])
{
int x1, x2, x3;
char s[16] = "38 02 14";
char t[16] = "38 08 14";
sscanf( t, "%i %i %i", &x1, &x2, &x3 );
printf( "x1 = %i, x2 = %i, x3 = %i\n", x1, x2, x3 );
sscanf( s, "%i %i %i", &x1, &x2, &x3 );
printf( "x1 = %i, x2 = %i, x3 = %i\n", x1, x2, x3 );
return 0;
}
The output using lcc-win32 sscanf is:
x1 = 38, x2 = 8, x3 = 14
x1 = 38, x2 = 2, x3 = 14
The output with gcc (under linux) or with Microsoft VC6++ is:
x1 = 38, x2 = 0, x3 = 8
x1 = 38, x2 = 2, x3 = 14
I can see why this should be. Can anyone here explain?
Thanks for your time
P.S. I have verified that there is no uppercase "O" that replaces
a zero. The "08" is well zero and then eight.
Why does it stop???