Constants • An integer constant like 2345 is an int • long constant is written with a terminal l or L : 100000000L • Unsigned constants are written with a terminal u or U ( ul means unsigned long) • A leading 0 (zero) on an integer constant means octal • A leading 0x or 0X means hexadecimal • Example: 30 = 036 = 0x1e • Another example: 0XFUL is an unsigned long constant with value 15 decimal • A character constant is an integer, written as one character within single quotes, such as ' a ' • The value of a character constant is the numeric value of the character in the machine's character set • Example: ' 0 ' has the value 48 in the ASCII character set • Character constants participate in numeric operations just as any other integers • Certain characters can be represented by escape sequences - example: ' \n ' (newline) - these sequences look like two or more characters, but represent only one • An arbitrary byte-sized bit pattern can be
' \ ooo '
where ooo is one to three octal digits (0...7)
• or by
' \x hh '
where hh is one or more hexadecimal digits
( 0...9 , a...f , A ...F )
... zobacz całą notatkę