Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language, help me explain it, I can't understand it.
C language, help me explain it, I can't understand it.
The sentence 1, because the printf statement is used in the program, contains the stdio.h header file to explain the calling rules of this function to the compiler. For details, please refer to Baidu Encyclopedia printf to tell you the header files that this function must refer to.

In the second sentence, the main function is the starting position of your program, and the program starts to execute from here. The void modifier in front indicates that this function does not return a value, which also means that the return (end) statement of the function can be written as return; If this sentence is the last sentence of main, it can also be omitted (for example, omitted)

The third sentence defines two integer variables, A and B (only the memory cell names of integers can be stored), where A has no initial value and its value is uncertain, and B is assigned to integer 322.

The fourth sentence defines two floating-point variables X and Y (which can store floating-point numbers, that is, data with decimals), where X is not assigned and Y is assigned to 8.88.

In the fifth sentence, two variables c 1 and c2 are defined to store character data, where c 1 stores the ASCII code of lowercase character K.

In the sixth sentence, the variable a is assigned a value. Since A is integer data, the value of 8.88 of the floating-point variable Y is converted into an integer (that is, the decimal part is discarded and only the integer part is taken), and the value stored in A is 8 after the assignment is completed.

The seventh sentence assigns a value to X. Because the data stored in B is integer data, it is necessary to take out the data 322 stored in variable B and forcibly convert it into floating point number 322.0 to assign it to X.

The eighth sentence assigns a value to A and takes out the ASCII code of lowercase letter K stored in c 1. This code is 107, which can be Baidu ASCII code. Look up the ASCII code value corresponding to the lowercase letter k in the code table, and assign 107 to A, and the data originally stored in A will be washed away.

The ninth sentence assigns a value to c2, takes out the data stored in B, and forcibly converts the type bit character type (because c2 is a character variable, and the value of the character variable is 0 ~ 255). The actual assignment is 322 divided by the remainder 66 of 256.

The last sentence calls the printf function to output the values of some variables to the display screen. The 1 th digit is the value of the variable A. Since A is an integer variable described by %d, the value of the variable A is output followed by a comma, then the value of the variable X decorated by %f is output, then the comma, then the value of the integer variable A, and finally the character (described by %c), that is, the character corresponding to the data stored in c2.

The last b is the character corresponding to the data (ASCII code) 66 stored in c2, which can be obtained by Baidu ASCII code lookup table.