I need to input 3 full names separated by commas
Full Name 1: John, Smith, Flynn
Full Name 2: Walter, Kennedy, Roberts
Full Name 3: Sam, Bass, Clinton
Then output it like this
First Name 1: John
First Name 2: Walter
First Name 3: Sam
Middle Name 1: Smith
Middle Name 2: Kennedy
Middle Name 3: Bass
Last Name 1: Flynn
Last Name 2: Roberts
Last Name 3: Clinton
How do i do these? so far this is my code
include #<iostream>
include #<cstdio>
include #<cstring>
using namespace std;
int main () { char first[3][100]; char middle[3][100]; char last[3][100]; char full[3][100]; int i;
cout << "Enter 3 Full Names <first, middle and last names separated by comma>:" << endl; for (i=0; i<3; i++) { cout << "Full Name " << i+1 << ":" ; gets (full[i]); }
cout << "The first names are: " << endl; for (i=0; i<3; i++) { strcpy (first[i], full[i]); if (strcmp (first[i], ", ")) { cout << "First Name "<< i+1 << ":" ; strcpy ( first[i], full[i] ); cout << (first[i]); cout << endl; } } cout << "The middle names are: " << endl; for (i=0; i<3; i++) {
cout << "Middle Name "<< i+1 << ":" ; cout << (middle[i]); cout << endl; }
cout << "The last names are: " << endl; for (i=0; i<3; i++) {
cout << "Last Name "<< i+1 << ":" ; cout << (last[i]); cout << endl; }
system("pause"); return 0; }