int firstNameL = First_Name.length()+3;
int middleInitialL = Middle_Initial.length();
int lastNameL = Last_Name.length();
int totalNameL = firstNameL + middleInitialL + lastNameL;
int commaPosition = Last_Name.length();
after this I just Cout << everything as I need to, and return 0. The program works just fine, but it is not using a single variable string.
I know how to do this problem using individual string variables for each first middle last name, but...
How do I do this using a single string variable and then determine substrings and lengths?
I need the program to store the input into a single variable string, find the substring lengths and save them to individual string variables, then combine them in a different order with a comma into a new single variable string. Then, need to display the position of the comma in the new string, and finally swap first name and last name and display them.
I need the program to store the input into a single variable string
Seeing as they are strings, you can just do the following to get them in to a single string: string fullName = First_Name + ' ' + Middle_Initial + ' ' + Last_Name;
find the substring lengths and save them to individual string variables
You've already done this:
1 2 3
int firstNameL = First_Name.length()+3;
int middleInitialL = Middle_Initial.length();
int lastNameL = Last_Name.length();
then combine them in a different order with a comma into a new single variable string