This is the problem i am supposed to solve : Proceed as in Exercise 6, but design the function to accept a single string object
Consisting of a first name, a middle name or initial, and a last name. As before,
the function should return a single string consisting of the last name, followed by
a comma, and then the first name and middle initial. For example, given "John
Quincy Doe", the function should return the string "Doe,John Q."
Here is my code thus far :
#include <iostream>
#include <string>
using namespace std;
void swap (string , string , string );
string name (string);
int main()
{
string first,middle,last;
string fullname;
cout <<"Enter your fullname [first,middle and last] : ";
cin >> fullname;
cout <<"\nThe name you entered is: "<< fullname ;
swap ( first,middle,last);
cout << "\nYour listed name is: " << first +"," + last + " "+ middle.at(0)<< endl;
}