← All topics
Quiz: Strings in C++: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What does this print? (code)
- Q2. What does find return when the text is not found?
- Q3. What does this print? (code)
- Q4. After cin n;, why does getline(cin, line); often return an empty string?
- Q5. What does this print? (code)
- Q6. Which call splits "a;b;c" into its parts?
- Q7. What is the difference between s[i] and s.at(i)?
- Q8. Why does the replace-all loop add pos += to.size() after each replacement?
- Q9. What does this print? (code)
- Q10. Which is the simplest way to check whether two words are anagrams?