← 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?
- A.cin >> s;
- B.getline(cin, s);
- C.scanf("%s", s);
- 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 →