Home > Back-end >  C language small white
C language small white

Time:09-20

Why write code output is 343597384?


# include
# define PI 3.14
Int main () {
Int a=8;
Printf (" % d ", a + PI);
}

CodePudding user response:

Printf (" % d ", a + PI);
Should be changed to the printf (" % lf ", a + PI);
Reason: IP has a value of 3.14, output floating point types of data placeholder with % lf,
In memory, no matter what kind of data type, are the binary code of the length of the corresponding access,
Data access is from within, if not according to the way of defining the data type of the data, the data will be wrong,
  • Related