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]

do I need to report this in the bug list?


#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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]