sscanf - %li query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux