#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. 20165206 2017-2018-2 《Java程序设计》第6周学习总结

    20165206 2017-2018-2 <Java程序设计>第6周学习总结 教材学习内容总结 String类:可以被直接使用,不可以有子类. String对象:可以使用String类声明 ...

  2. 微信小程序API 登录-wx.login(OBJECT) + 获取微信用户唯一标识openid | 小程序

    wx.login(OBJECT) 调用接口获取登录凭证(code)进而换取用户登录态信息,包括用户的唯一标识(openid) 及本次登录的 会话密钥(session_key).用户数据的加解密通讯需要 ...

  3. Git基础(二) 文件的生命周期

    使用Git时,文件的生命周期如下:

  4. UTC时间戳转为时间

    /// <summary> /// 将UTC时间转化DateTime时间 /// </summary> /// <returns></returns> ...

  5. file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.73-8.el6_8.i686

    1:也许之前的机器安装过Mysql,但是自己不知道,账号密码也忘记了,又执行安装操作,导致Mysql不兼容问题.Linux上安装MySQL时出现不兼容的解决办法,错误如下所示: [root@maste ...

  6. jQuery字体缩放缩放插件zoomFontSize.js

    插件描述:jQuery字体缩放缩放插件zoomFontSize.js根据父类进行百分比缩放,兼容性如下: 使用方法 body 的class属性 添加 changbody_fontSize 而且整个页面 ...

  7. MQ消息队列之MSMQ

    主要参考文章: 消息队列(Message Queue)简介及其使用

  8. jenkins X实践系列(4) —— jenkins X 构建提速

    jx是云原生CICD,devops的一个最佳实践之一,目前在快速的发展成熟中.最近调研了JX,这里为第4篇,介绍如何加入jx构建和部署. builder镜像下载慢 先在一台机器上下载好,然后放到本地仓 ...

  9. Oozie

    Oozie的功能模块 workflow 由多个工作单元组成 工作单元之间有依赖关系 MR1->MR2->MR3->result hadoop jar:提交1个MR oozie:监控当 ...

  10. 025 SSM简单搭建

    参考了同事的文档,自己也写一篇文档. 同时,补充了一下,程序是如何运行的. 一:SSM框架 1.说明 SSM(Spring+SpringMVC+MyBatis)框架集由Spring.SpringMVC ...