



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




FUNCTION MEANING
isalpha true if arg. is a letter, false otherwise isalnum true if arg. is a letter or digit, false otherwise isdigit true if arg. is a digit 0-9, false otherwise islower true if arg. is lowercase letter, false otherwise isprint true if arg. is a printable character, false otherwise ispunct true if arg. is a punctuation character, false otherwise isupper (^) true if arg. is an uppercase letter, false otherwise isspace true if arg. is a whitespace character, false otherwise
H i t h e r e! \
const int SIZE = 100; char fname[SIZE] = "Maureen", name[SIZE]; strcpy_s(name,fname);
Definition Meaning string name; defines an empty string object string myname("Chris"); (^) defines a string and initializes it string yourname(myname);
defines a string and initializes it string aname(myname, 3);
defines a string and initializes it with first 3 characters of myname string verb(myname,3,2);
defines a string and initializes it with 2 characters from myname starting at position 3 string noname('A', 5); (^) defines string and initializes it to 5 'A's
OPERATOR MEANING
extracts characters from stream up to whitespace, insert into string << inserts string into stream = assigns string on right to string object on left += (^) appends string on right to end of contents on left
, >=, <, <=, ==, !=
relational operators for string comparison. Return true or false
string word1, phrase; string word2 = " Dog"; cin >> word1; // user enters "Hot Tamale" // word1 has "Hot" phrase = word1 + word2; // phrase has // "Hot Dog" phrase += " on a bun"; for (int i = 0; i < 16; i++) cout << phrase[i]; // displays // "Hot Dog on a bun"
string word1, word2, phrase; cin >> word1; // word1 is "Hot" word2.assign(" Dog"); phrase.append(word1); phrase.append(word2); // phrase has "Hot Dog" phrase.append(" with mustard relish", 13); // phrase has "Hot Dog with mustard" phrase.insert(8, "on a bun "); cout << phrase << endl; // displays // "Hot Dog on a bun with mustard"