您的位置:首页 > 编程语言 > C语言/C++

编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习3

2013-11-20 15:08 471 查看
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char fname[20];
char lname[20];
char name[45];
cout<<"Enter your first name: ";
cin.getline(fname,20);
cout<<"Enter your last name: ";
cin.getline(lname,20);
strcpy(name,lname);
strcat(name,", ");
strcat(name,fname);
cout<<"Here's the information in a single string: "<<name<<endl;
system("pause");
return 0;
}

运行结果:

Enter your first name: Flip

Enter your last name: Fleming

Here's the information in a single string: Fleming, Flip
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐