Chapter 7 Exercise Set 0: Chapter Review

  1. Write the code from the Containers for strings section in a file named hello_strings.cpp, compile it, and run it.

  2. Write a function that takes a string as an argument and that outputs the letters backwards, all on one line.

  3. Encapsualte the code from the Looping and counting section in a function named count_letters, and generalize it so that it accepts both the string and the letter as arguments.

  1. Rewrite the count_letters function from the previous exercise so that instead of traversing the string, it uses the find function.

  2. Fix the code in String concatenation so that “Ouack” and “Quack” are spelled correctly.

  3. Use the cctype library write functions string_to_upper and string_to_lower that take a single string as an argument and return a string consisting of all upper or lower case letters.

ASCII values and the compare member function

  1. Look up the decimal value of the character 'A' in the ASCII table. Now do the same for the character 'x'.