🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Strings in C++: all 10 questions

Quiz: Strings in C++ · Question 6 of 10

Which call splits "a;b;c" into its parts?

Which call splits "a;b;c" into its parts?

  1. A.ss >> part with stringstream ss("a;b;c")
  2. B.getline(ss, part, ';') in a loop
  3. C.s.substr(';')
  4. D.s.find(';', true)
Answer & explanation

Correct answer: getline(ss, part, ';') in a loop

getline with a delimiter reads up to each ';'. The >> operator only splits at whitespace.

Can you get the rest right without peeking?

Take the timed Quiz: Strings in C++ quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →