简体   繁体   中英

How do I take input from the user of their full name, and then output their first name and last name seperately? (C++)

I only so far made the outline, and I just don't know how to continue onwards with it, I am stumped.

Example output should be:

  • enter your full name
  • xfdgchkv loyloyloy
  • your name is xfdgchkv and surname is loyloyloy
#include <iostream>
#include <string>

using namespace std;

int main()  {
    string fullName;
    string firstName;
    string lastName;
    cout << "please input your full name, specifying only your last and first name" << endl;
    cin >> fullName;
    fullName = firstName + lastName;

cin ignore space/new-line, so you can use this:

cin >> firstname >> lastname;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM