Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Why in C language, when an unsigned long integer and an integer type are input together, the integer type is not assigned a value?
Why in C language, when an unsigned long integer and an integer type are input together, the integer type is not assigned a value?

Just write scanf("%u%d",&num1,&num2), and remove the l after u; because scanf treats l as a common character between %u and %d. Similar to a comma, so when you enter two numbers, you cannot skip l and assign the exact value to the following num2;

You can also try entering 4294967295l3333, and the second integer can be assigned normally. ;

The result after removing l is:

The code is as follows:

int

main(void)

< p>{

unsigned

long

num1;

long

num2;

< p>long

lRc=0;

lRc=scanf("%u%d",

&num1,

&num2) ;

//When lRc is 1, it means that only one value was successfully entered; when it returns 2, it means that 2 values ??were successfully entered;

printf("The input is [%d]: %u

%d\n",lRc,num1,num2);

}

(I just answered it once, I don’t know where the answer is.

} p>

=

=! )