
 //Dione Torrevillas                 CS1A                 Chapter 10, P. 589, #7
 /******************************************************************************
 * NAME ARRANGER
 * This program accepts the user's first, middle, and last
 * names and arranges them with the last name appearing first.
 *
 * INPUT:
 *     firstName  : User's first name
 *     middleName : User's middle name
 *     lastName   : User's last name
 *
 * OUTPUT:
 *     fullName   : Arranged full name
 ******************************************************************************/
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    const int SIZE = 50;
    char firstName[SIZE];
    char middleName[SIZE];
    char lastName[SIZE];
    char fullName[160];

    // Get the first, middle, and last names.
    cout << "Enter your first name: ";
    cin.getline(firstName, SIZE);

    cout << "Enter your middle name: ";
    cin.getline(middleName, SIZE);

    cout << "Enter your last name: ";
    cin.getline(lastName, SIZE);

    // Arrange the names in the fourth array.
    strcpy(fullName, lastName);
    strcat(fullName, ", ");
    strcat(fullName, firstName);
    strcat(fullName, " ");
    strcat(fullName, middleName);

    // Display the arranged name.
    cout << "Arranged name: " << fullName << endl;

    return 0;
}
