#include <iostream>
#include <string>
using namespace std;
int main()
{
 string fname;
 string lname;
 string name;
 cout<<"Enter your first name: ";
 getline(cin,fname);
 cout<<"Enter your last name: ";
 getline(cin,lname);
 name=lname+", "+fname;
 cout<<"Here's the information in a single string: "<<name<<endl;
 system("pause");
 return 0;
}

与使用char数组和头文件cstring中的函数比较,string对象和string中函数,操作简单,尤其对复杂的问题优势更加明显。

编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习4的更多相关文章

  1. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9

    #include <iostream> #include <fstream> #include <cstdlib> #include <string> ...

  2. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8

    #include <iostream> #include <fstream> #include <cstdlib> const int SIZE=20; using ...

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

    #include <iostream> #include <string> #include <cctype> using namespace std; int m ...

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

    #include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...

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

    #include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...

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

    #include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...

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

    #include <iostream> using namespace std; void showmenu(void) { cout<<"Please enter ...

  8. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2

    #include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int mai ...

  9. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习1

    #include <iostream>#include <cctype>using namespace std;int main(){ char ch; while((ch=c ...

  10. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习9

    #include <iostream>using namespace std;int main(){ int num; cout<<"Enter number of ...

随机推荐

  1. Tomcat使用

    打开Tomcat官网 在浏览器地址栏输入: tomcat.apache.org,按回车 下载Tomcat 把目光移动至网页左边红匡处,点击Tomcat8 网页下移 点击箭头所指的链接 运行Tomcat ...

  2. Django-model基础

    Django-model基础 在Django-ORM中表和类存在映射关系 表名<------------>类名 字段<------------>属性 表记录<------ ...

  3. DevExpress中的GridControl控件设置了列Readonly后,想双击弹出明细的实现

    OptionsBehavior.Editable = true时,会有二个对象触发事件:view触发ShownEditor 事件(第一单击时)和内置编辑器的DoubleClick事件所以必须处理这二个 ...

  4. snmp v3的安全配置 snmp认证与加密配置(53)

    http://www.ttlsa.com/zabbix/snmp-v3-configuration/

  5. POJ 1273 Drainage Ditches【最大流模版】

    题意:现在有m个池塘(从1到m开始编号,1为源点,m为汇点),及n条有向水渠,给出这n条水渠所连接的点和所能流过的最大流量,求从源点到汇点能流过的最大流量 Dinic #include<iost ...

  6. adb devices unauthorized解决办法

    进行Android项目调试时,连接完设备,进行adb install ******.apk时,偶遇 adb devices unauthorized 这个小东西,解决办法:将手机设置->辅助功能 ...

  7. npm淘宝镜像的设置和删除

    设置 npm config set registry https://registry.npm.taobao.org npm config set disturl https://npm.taobao ...

  8. net core体系-web应用程序-4asp.net core2.0 项目实战(1)-5项目数据库操作封装操作-EF框架

    EF框架有三种基本的方式:DB First(数据库优先),Model First(模型优先),Code First(代码优先). Entity Framework4.1之前EF支持“Database  ...

  9. net core体系-web应用程序-4net core2.0大白话带你入门-4asp.net core配置项目访问地址

    asp.net core配置访问地址  .net core web程序,默认使用kestrel作为web服务器. 配置Kestrel Urls有四种方式,我这里只介绍一种.其它方式可自行百度. 在Pr ...

  10. aop日志记录

    1.自定义 package cc.mrbird.common.annotation; import java.lang.annotation.ElementType; import java.lang ...