Why is the getline function the preferred way to read string values into your program instead of the cin object?

What will be an ideal response?


The getline reads until it sees an Enter key, and reads data that includes spaces. The cin object reads until it sees white space or an Enter key. Therefore, if you want to enter “Today is Sunday.” you should use a getline. If you read that input line using cin, all you would obtain is “Today”.

Computer Science & Information Technology

You might also like to view...

Which of the following pseudocode statements express the condition below?A movie theater admits a customer free if he or she is under 2 years old or if he or she is 65 or older.

A. If age < 65 Or age >=2 Then    admissionPrice = 0 Else    admissionPrice = regularPrice B. If age < 2 Or age <= 65 Then    admissionPrice = 0 Else    admissionPrice = regularPrice C. If age > 2 Or age < 65 Then    admissionPrice = 0 Else    admissionPrice = regularPrice D. If age < 2 Or age >=65 Then    admissionPrice = 0 Else    admissionPrice = regularPrice

Computer Science & Information Technology

Which of the following are the two categories of fire suppression systems?

a. Wet pipe and dry pipe b. Wet fire and dry fire c. Flammable fire and electric fire d. Wet fire and electrical fire

Computer Science & Information Technology

?Project planning, an activity of a project manager, _____.

A. ?involves requires guiding, supervising, and coordinating the a project team's workload B. ?includes monitoring the progress of the a project, evaluating results, and taking corrective action when necessary to stay on target C. ?focuses on long-term challenges and goals, the importance of stakeholders, and a commitment to the firm's role as a corporate citizenconsists of staffing, which includes selecting the project team and assigning specific tasks to team members D. ?includes identifying project tasks and estimating completion times and costs

Computer Science & Information Technology

In a(n) ____, we move back and forth between different viewpoints, criticizing each and trying to learn from each.

A. encryption scheme B. dialectic C. utilitarian scheme D. PGP

Computer Science & Information Technology