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

Quiz: C++ Introduction · Question 2 of 10

Which reads a full line including spaces into a string s?

Which reads a full line including spaces into a string s?

  1. A.cin >> s;
  2. B.getline(cin, s);
  3. C.scanf("%s", s);
  4. D.cin.get(s);
Answer & explanation

Correct answer: getline(cin, s);

cin >> stops at the first space.

Can you get the rest right without peeking?

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

Start the quiz →