Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language example [integer data overflow] The second example
C language example [integer data overflow] The second example
When c and d are defined as long, each variable under TC accounts for 4 bytes.

Use %ld format (take 4 bytes) to get correct output.

If% d (2 bytes lower than %d(TC)) is used,

printf("c=x+a=%d,d=y+b=%d\n ",c,d);

The low 16 bit of c (corresponding to decimal value 12) is passed to the first% d.

The high 16 bit (value 0) of c in the internal function is passed to the second% d.

Do not use the value of d.

So what you said happened.

It is correct under VC6, because in VC6, int and long are also 4 bytes, and %d and %ld are all 4 bytes.