Problem with find() and substr() functions

Hello! I'm trying to figure out how to use the find() and substr() functions to extract the first and last names of the user when they input their name. Here is my code:

# include<string>
# include<iomanip>
# include <iostream>

using namespace std;

int main()

{

cout << "Enter your name(last,first): "<<endl;
string lastname,firstname;
cin lastname,firstname;

cout << "First name: " << << "Last name: "<< <<endl;

return 0;

} This is what I have so far.

I want it so that the user inputs their name in the desired format that I put there(last,first) and is able to show up on the last statement line as it shows. I'm supposed to use the find() and substr() and I have to use the "lastname,firstname" as a string and extract the first and last name from there using the find() and substr() functions but I'm having a hard time and I was wondering if I can please get some assistance. I would really appreciate the help. Thank you!
You are declaring two variables: lastname and firstname. Do you want to read only one string?
Topic archived. No new replies allowed.