Download - CS2311 Computer Programming
Introduction to Programming
Dr. Yang, QingXiong(with slides borrowed from Dr. Yuen, Joe)
LT8: Characters and Strings
CS2311 Computer ProgrammingOutline2Characters Declaration and InitializationASCII
ASCII Code
3Outline4Characters Declaration and InitializationASCII Input and Output (cin,cout)Strings Declaration and InitializationCopy and compareInput and output
Syntax Summary5KeywordscharPunctuators[], , Constant \n , \0
Character data type6Written between single quotes. Examples'A', 'b', '*'In C++ language, a char type is represented by an integer.Therefore, a character can also be treated as an integer
6Character type examples7cout c2;
CScin >> c3;
CS2char c1,c2,c3;cin >> c1; //enter the string "CS2311"cin >> c2; //get the character 'S' from buffercin >> c3; //get the character '2' from buffer
Printing a character14char c1='A',c2='B';cout > c;if ( )//'A'-'Z'cout