Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Because A is a real variable, the assignment a= 10 is allowed in C program, so real variables are allowed to store integers? Why is it wrong?
Because A is a real variable, the assignment a= 10 is allowed in C program, so real variables are allowed to store integers? Why is it wrong?
It doesn't matter what value is stored in each storage unit of the computer. The key is how the compiler treats them.

C compiler treats real data as floating point numbers, so it will generate a machine code with floating point operation for variables declared/defined as real types, so any type of variables can be put at will, but it is uncertain whether the compiler will let you successfully express what you want to express.

For example: char a;; a = 1; And a ='1'; Isn't the difference obvious? One is assigned with a plastic literal value, and the compiler will automatically encode it with ascii, and then assign the value. The other is to assign character literal values, and the compiler will use ascii codes directly.

Another example is; Floating a; A = 3.0 and a =1; What is the difference? 3.0 and 1 are real face value and plastic face value respectively, which are just a number stored in the storage unit. Different use methods will produce different results. For example, it is possible to change exe to bmp, but it may be messy.

Please accept it if you are satisfied, and ask if you are not satisfied.