#include <iostream>
#include <string>
#include <array>
usingnamespace std;
int main()
{
char choice;
int n;
string st;
do
{
cout << "Please enter your full name: " << endl;
getline(cin, st);
//find last name
int n = st.find
cout << st << ", your last name is: ";
system("PAUSE");
return 0;
}
I'm not too sure on how to find the last name, should I try and find the character of a space then input the string after that?
I think yeah you'll need to find space character first and use this www.cplusplus.com/reference/string/string/substr/
To find character in string
www.cplusplus.com/reference/string/string/find_first_of/
Logically I have to find the last word before the return key and after the space, but how would I input this into code with using only the members of the string library?
Sorry for really late answer ._.)'
I found something on the net
1 2 3 4 5 6 7 8 9
int main(){
int age = 0;
string name = "";
cout<<"Enter your age ";
cin>>age;
cout<<"Enter your name ";
getline(cin, name);
return 0;
}
If you run this program and press enter after
entering your age, then that's it. That '\n'
character will go and get saved as a string in the
variable name.