Question: C++ Debug and write comments in the lines where there were errors, and explain it. #include #include using namespace std; int main() { string firstLast
C++ Debug and write comments in the lines where there were errors, and explain it. #include#include using namespace std; int main() { string firstLast = ; string first = ; string last = ; int spaceLocation = 0; //get first and last name cout << "Name (first and last only): "; getline(cin, ); //locate space, then pull out first and last names spaceLocation = firstLast.find(" ", 0); first = firstLast.substr(1, spaceLocation); last = firstLast.substr(spaceLocation + 2); //display rearranged name cout << last << ", " << first << endl; return 0; } //end of main function
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
