Question 5
Back to Exercise
Which call reads a whole line such as Rahul Kumar Sharma into a std::string?
- A std::cin >> name;
- B std::getline(std::cin, name); Correct
- C std::cin.get(name);
- D std::cin.read(name);
Correct Answer: Option B
std::cin >> name stops at the first space and would read only "Rahul".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!