C++中string类的基本用法

 1 #include <iostream>
 2 #include <set>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     string line;
 9     getline(cin,line,'-');   //getline用法
10     cout<<line<<endl;
11     cout<<line.size()<<endl;  //<iostream>中包含<string>
12     cout<<line[0]<<endl;  //访问数组中的字符
13 
14     return 0;
15 }

 

posted @ 2016-03-23 21:08  hu983  阅读(143)  评论(0编辑  收藏  举报