All i need to do is to parse the input string of your full name, into 3 separate names so I can take the first initials of each and print them. Can anyone point me in the right direction?
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
string [parsed_output] = fullName.split(" ");
string firstName = parsed_output[0];
string middleName = parsed_ouput[1];
string lastName = parsed_output[2];
string fullName;
char firstLetter = firstName[0];
char middleLetter = middleName[0];
char lastLetter = lastName[0];
cout << "Enter your first name, middle name or initial, and last name separated by spaces: \n";
cin >> fullName;
cout << "Your initials are: " << firstLetter << middleLetter << lastLetter << '\n';
cout << "Your name is: " << firstName << " " << middleName << " " << lastName << '\n';
return 0;
}
length() > 0printsubString[0]. As shown in the answers below, you can also just take the names separately. Unless processing the complete name at once is an absolute requirement.fullNameis not declared, and you want to parse it before putting anything into it? I think you need some basics first.