Saint Louis University |
Computer Science P125
|
Dept. of Math & Computer Science |
Topic: Using String Objects
Related Reading: Ch. 3
Due:
Friday, 11 February 2005, 12:00pm
Please make sure you adhere to the policies on academic integrity.
Please note that the answer to "self-check" questions from the text are available via the author's website.
Any of Self-Check Questions 17-26 of Ch. 3 are relevant (pages 128-129)
Consider the following declarations:
string greet = "Hello!";What is the output of each of these subsequent code fragments?
string welcome = "Welcome to computer science";
string com = "to";
cout << greet.size() << endl;
cout << welcome.size() << endl;
cout << (com+com) << endl;
cout << welcome.substr(8,5) << endl;
cout << welcome.substr(5,8) << endl;
cout << welcome.find("e") << endl;
cout << welcome.find("e",10) << endl;
cout << welcome.find("com") << endl;
cout << welcome.find("com",5) << endl;
cout << welcome.find(com) << endl;
Exercise 3.31 of the text (p. 151)
A code fragment is sufficient (i.e. you do not need to specify
all of the typical header information needed for a truly
compilable program).