do I need to report this in the bug list?

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

 



#include <stdio.h>

int
main(int ac, char **av)
{
    unsigned short int a;
    unsigned short int b;

    printf("Enter a: ");
    scanf("%d", &a);
    printf("a = %d\n\n", a);

    printf("Enter b: ");
    scanf("%d", &b);

    printf("a = %d\n", a);
    printf("b = %d\n", b);
}

Output of the program:
Enter a: 12
a = 12

Enter b: 53
a = 0
b = 53

My problem is that a, becomes zero after the scanf operation of b. And when
I tried to use %h instead of %d the program did even stop for the inputs. I
can avoid the zeroing of if and i declare another short variable between a &
b.

is there any compiler option that I need to enable for compiling this
rightly.

Thanks

[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