This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]