c++随笔【string】

//
//  main.cpp
//  cpplearn1
//
//  Created by myhaspl on 2017/12/3.
//  Copyright © 2017年 [email protected]. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    //getline以换行符为终止,去掉换行符,
    //而get以换行符为终止,但不丢弃换行符,
    //将其留在输入队列中。

    string y1;
    string y2;
    string y3 {"==>good"};

    cout<<"input a string=>y1:";
    getline(cin,y1);
    cout<<"input a string=>y2:";
    getline(cin,y2);
    
    cout<<y1<<endl;
    cout<<y2<<endl;
    cout<<y1+y2+y3<<endl;

    return 0;
}

input a string=>y1:hello

input a string=>y2:world

hello

world

helloworld==>good

Program ended with exit code: 0


猜你喜欢

转载自blog.csdn.net/u010255642/article/details/78976581
今日推荐