For example, there are the following statements:
View plain text
int a = 1234;
Then int in the statement is data type, a is variable, and 1234 is literal value. The literal value of int is what can be used to initialize variables of type int (don't say that it can be initialized with other variables! )。
Similarly, the literal value of char is of course the machine's ASCII character set, which is divided into visible characters and invisible characters. There are two ways to express it, as shown in the following program:
# include & ltstdio.h & gt
int main(void)
{
/* Integer constant (literal value) */
//Decimal representation
int in = 1234;
Long ln =1234l;
Unsigned intuin =1234u;
Unsigned long integer uln =1234ul;
//hexadecimal representation
in = 0xabul
//Octal representation
in = 0 123 ul;
//No suffix means that the integer constant is short.
/* Character constant (literal value) */
//Universal representation
char c = ' x
//represented by an escape sequence
c = ' \ n
c = ' \ 100 '; // 1-3 octal number
C =' \ x4a/1-2 hexadecimal number
/*
* All escape sequences
* -
* \a (corresponding to a character with a value of 7 in the ASCII table (ringing))
* \b (value is 8 (backspace))
* \f \ '
* \n \ "
* \r \\
* \t \?
* \v \ooo \xhh
* -
* In particular, the escape sequence' \ooo' corresponds to a character with a value of 0000 (octal) in the ASCII table.
* '\xhh' corresponds to the character with the value of 0xhh (hexadecimal) in the table.
*/
/* floating point constant (literal value) */
float f =- 12.34 e- 1f; //floating
Double df =1234.56; // double
Long double LDF =1234.56L; // long double
/* String constant (literal value) */
/* Enumeration constant */
Enumeration month _t
{
JAN = 1, February, March, April, May, June,
July, August, September, October, November and December
};
Enum Month _ t m = MAR//C compiler does not check, but c++ compiler does.
Returns 0;
}