std::string 用法

例子:

#include <iostream>
#include <string>

using namespace std;
int main(){
   
    string strinfo="Alis";

    if( strinfo == "winter" )
        cout << "you are winter!"<<endl;
    else if( strinfo != "wende" )
        cout << "you are not wende!"<<endl;
    else if( strinfo < "winter")
        cout << "your name should be ahead of winter"<<endl;
    else
        cout << "your name should be after of winter"<<endl;

    cout << strinfo + " Welcome to China!"<<endl;
    cout <<"Your name is :"<<endl;
    string strtmp = "How are you? " + strinfo;
    for(int i = 0 ; i < strtmp.size(); i ++)
        cout<<strtmp[i];

    return 0;
}

输出:

you are not wende!
Alis Welcome to China!
Your name is :
How are you? Alis
全部评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务