This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
sscanf - %li query
- From: Rahul <rah dot v dot ragh at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 2 Jan 2009 11:35:32 +0530
- Subject: sscanf - %li query
Hello all,
Please help me with this example.
#include <stdio.h>
int main()
{
signed long v;
printf("sizeof(long) = %d\n", sizeof(long));
v = 0xFFFFFFFF;
printf("v-li = %li; v-lx = %lx\n", v, v);
sscanf("0xFFFFFFFF","%li", &v);
printf("v-li = %li; v-lx = %lx\n", v, v);
sscanf("0xFFFFFFFF","%lx", &v);
printf("v-li = %li; v-lx = %lx\n", v, v);
return 0;
}
Got the following output for the above code with gcc version 3.2.3.
sizeof(long) = 4
v-li = -1; v-lx = ffffffff
v-li = 2147483647; v-lx = 7fffffff
v-li = -1; v-lx = ffffffff
Why are values different when "%li" is used with 'sscanf'. Am I
missing something here or can this be a bug?
Request your guidance if this is not the correct place to post this query.
Thanks,
Rahul