简体   繁体   English

我如何从他们的全名的用户那里得到输入,然后 output 他们的名字和姓氏分开? (C++)

[英]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:示例 output 应该是:

  • enter your full name输入您的全名
  • xfdgchkv loyloyloy xfdgchkv 合金
  • your name is xfdgchkv and surname is loyloyloy你的名字是 xfdgchkv,姓氏是 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忽略空格/换行符,所以你可以使用这个:

cin >> firstname >> lastname;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从控制台输入学生的全名(包括空格)并将其存储在c ++中的数组中? - How do I take full name of students(including space) as input from console and store it in an array in c++? 如何输出以姓氏开头的全名? 如果名字或姓氏由单词组成怎么办? - How output a full name that starts with last name? What if the the first name or last name consist of words? 允许用户输入名字和姓氏; 向用户显示全名(第一个+最后一个) - Allow user to input first and last name; display full name back to user (first + last) 如何从 C++ 文件中读取由空格分隔的全名? - How do I read a full name that is separated by a space from a file in C++? 如何从 C++ 中的文件中读取用逗号分隔的全名? - How do I read a full name that is separated by a comma from a file in C++? C ++:使用逗号分隔文件中的名字和姓氏 - C++: separating first and last name from a file, separated by a comma LDAP获取完整的用户名C ++ - LDAP Getting Full user Name C++ 我被困在如何使用 C++ 中一个人的名字和姓氏在双向链表中进行排序算法 - I'm stuck on how to make a sorting algorithm in a doubly linked list using a person's first name and last name in C++ 从全名QString中获取名字和姓氏 - Get first name and last name out of a full name QString 除姓氏外,我该如何取名字的所有部分的首字母? - How do i take the initials of all the parts of one's name except the last name?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM