[ad_1]
This call of scanf
unsigned char in,b;
scanf("%u %u",&in,&b);
invokes undefined behavior because the function expects that its second and third arguments are pointers to objects of the type unsigned int
while actually they are pointers to objects of the type unsigned char
.
Instead you have to use the length modifier hh
with the conversion specifier u
scanf("%hhu %hhu",&in,&b);
From the C Standard (7.21.6.2 The fscanf function)
11 The length modifiers and their meanings are:
hh Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type pointer to signed char
or unsigned char.
[ad_2]