+ All Categories
Home > Documents > CS2311 Computer Programming

CS2311 Computer Programming

Date post: 30-Dec-2015
Category:
Upload: yuli-carpenter
View: 34 times
Download: 0 times
Share this document with a friend
Description:
CS2311 Computer Programming. Dr. Yang, QingXiong (with slides borrowed from Dr. Yuen, Joe) LT8: Characters and Strings. Outline. Characters Declaration and Initialization ASCII Input and Output Strings Declaration and Initialization Copy and compare Input and output. - PowerPoint PPT Presentation
Popular Tags:

of 58

Click here to load reader

Transcript

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


Recommended