Character Types
- char is an integer, is a special type: Character
- It represents a character in single quotes: 'a'
- '' It is a character
- printf and scanf with% c in output to input characters
Input and output characters
How to enter '1' to the character C char?
Scanf ( "% C", & C); Input 1
Scanf ( "% D", & I); C = I; input 49
Since '1' ASCII code is 49, so when c == 49, it represents '1'
Character computing
char c='A';
c++;
printf("%c",c);
\\输出结果为B
Press arrangement numbers 0 to 9;
letters are arranged in order, uppercase and lowercase letters are separately arranged;
'A' - 'A' distance between both ends can be obtained;
A + 'A' - 'A' can be a uppercase to lowercase letters
a + 'a' - 'a ' can be put into a capital letter lowercase
Mixed input
scanf ( "% d% c" , & i, & c);
reading an integer, then reading character, will read the digital space after
scanf ( "% d% c" , & i, & c);
reading an integer, then reading character, if space will read spaces, no matter behind
Character Types
- Escape character
used to express can not be printed out of control characters or special characters, it "\" at the beginning, followed by a character, a combination of the two together to form a backslash characters
such as: printf ( "Please enter feet tall and are inch, "" such as input \ "57 \" indicates 5 feet 7 inches: ");
can not occur within double quotes double quotes, so use \" to express double quotes
character | significance |
---|---|
\b | A grid fallback |
\t | Bit to the next table (a table for each grid of 4 bits) |
\n | Wrap |
\r | Enter |
\" | Double quotes |
\’ | apostrophe |
\\ | Backslash itself |