What does char define?
Char is a descriptor of character variables.

The value of a character variable is a character constant, that is, a single character. The type specifier of a character variable is char. The format and writing rules of type description of character variables are the same as those of integer variables.

For example:

char a,b; Each character variable is allocated a byte of memory space, so only one character can be stored. Character values are stored in the storage unit of variables in the form of ASCII codes. Like x

The decimal ASCII code is 120, and the decimal ASCII code of y is 12 1. Assign "X" and "Y" values to character variables A and B: A = "X"; B =' y Actually, the binary codes of 120 and 12 1 are stored in two units: A0 1 1000.

b 0 1 1 1 1 0 1

So they can also be regarded as integral quantities. C language allows assigning character values to integer variables and integer values to character variables. When outputting, it is allowed to output character variables as integers and integers as characters. The integer number is two bytes and the character number is one byte. When processing integer numbers according to the number of characters, only the lower octets participate in the processing.

Master ()

{

char a,b;

a = 120;

b = 12 1;

printf("%c,%c\n%d,%d\n ",a,b,a,b);

}

a ■ b ■

a & lt- 120

b & lt- 12 1

Show program results

This program shows that A and B are character types, but they are given integer values in the assignment statement. From the results, the output form of a and b values depends on the format symbols in the format string of printf function. When the format symbol is "C", the corresponding output variable value is a character, and when the format symbol is "D", the corresponding output variable value is an integer.

void main()

{

char a,b;

a = ' x

b = ' y

a = a-32;

b = b-32;

printf("%c,%c\n%d,%d\n ",a,b,a,b);

}