Question: #include #include using namespace std; int main ( ) { string userName; string userAddress; cout < < ; getline ( cin , userName
#include
#include
using namespace std;
int main
string userName;
string userAddress;
cout ;
getlinecin userName;
cout ;
getlinecin userAddress;
cout userName endl;
cout userAddress endl;
return ;
zybook tells me its wrong cin is used to read the string variable userName from input, since the name is assumed to be a single word.
Then, getline is used to read the string variable userAddress from input, since the address is assumed to contain multiple words.
Ex: For input Rob Second Avenue, the cin statement gets characters until the next whitespace, so "Rob" is read, stopping at the space after Rob. Then, the getline statement gets all the remaining text on the input line, so Second Avenue" is read, including the leading space.
what am i doing wrong?
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
