演示使用string对象

#include<iostream>
#include<string>

using namespace std;
void main()
{
    string str1("i am here!");
    string str2="where are you?";
    cout << str1[0] << str1[9] << "," << str1 << endl;
    cout << str2[0] << str2[13] << "," << str2 << endl;
    cout << "please input you name:";
    cin >> str1;
    cout << str1 << endl;
    cout << "length of the name is :" << str1.size() << endl;
    cout << str2 + " " + str1 << endl;
}

输出结果

 

end!

posted @ 2016-03-12 01:06  知_行  阅读(158)  评论(0编辑  收藏  举报