I'm having trouble with this code. I want it to take 2 words and it's always ignoring the first word and then taking the 2nd word. If I put in 3 words, it works perfectly and picks up the final 2 words. The prompt for this is these bullet points.
- Prompt the user to enter his/her first and last name.
- Read the name from the keyboard using the getline method and store it into a variable called fullName (you will need to declare any variables you use).
- Print out the fullName.
- Compile, debug, and run, using your name as test data.
- Since we are adding on to the same program, each time we run the program we will get the output from the previous tasks before the output of the current task.
How do you make this work correctly?
string fullName;
cout << "What is your full name" << endl;
cin >> fullName;
getline(cin, fullName);
cout << fullName << endl;
cout << endl;