22.String - ++String in C String Series of characters...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ++String in C String Series of characters enclosed in double quotes. Philadelphia University String can be array of characters ends with null character \0. char sname[ ] = Ali Samer; // 10 locs or char sname[ ] = {A,l,i, ,S,a,m,e,r,\0} String String can be constant pointer that points to the strings first character. char *sname = Ali Samer; Sname points to A Ali Samer\0 in Some where in memory Example void main( ) { char firstName = "Ahmad"; char *lastName = "Omar"; cout<<"First Name: "<<firstName<<endl; cout<<"Last Name: "<<lastName<<endl; int i=0; cout<<"FirstName: "; while (firstName[i] != '\0') cout<<firstName[i++]; i=0; cout<<"\nLast Name: "; while (lastName[i] != '\0') cout<<lastName[i++]; } Reading String char studentName[20]; cin>>studentName; cout<<studentName<<endl; Problem : read characters until the first white space. Reading String solution : use cin.getline(array_name, array_size, delimiter): use cin....
View Full Document

This note was uploaded on 02/23/2011 for the course CHEMICAL E 2 taught by Professor Hibasaadeh during the Spring '11 term at University of Jordan.

Page1 / 13

22.String - ++String in C String Series of characters...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online