Question: / / This program illustrates a problem that can occur if / / cin is used to read character data into a string object. /
This program illustrates a problem that can occur if
cin is used to read character data into a string object.
input a name with first and last space between and observe the bug, then fix
#include
#include Header file needed to use string objects
using namespace std;
int main
string name;
string city;
cout "Please enter your name: ;
cin name;
cout "Enter the city you live in: ;
cin city;
cout "Hello, name endl;
cout "You live in city endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
