std::string

 1 /*************************************************************************
 2     > File Name: string.cpp
 3     > Author: lukey
 4     > Mail: lukey123@foxmail.com 
 5     > Created Time: Wed 10 Jun 2015 09:21:32 PM CST
 6  ************************************************************************/
 7 
 8 #include<iostream>
 9 //using namespace std;
10 
11 int main(int argc, char* argv[])
12 {
13     std::string str1 = "hello";
14     std::string str2("world");
15     std::cout << "str1:" << str1 << std::endl;
16     std::cout << "str2:" << str2 << std::endl;
17     std::string str3 = str1 + str2;
18     std::cout << "str3:" << str3 << std::endl;
19     std::string sub1 = str3.substr(0,5);
20     std::string sub2 = str3.substr(8,2);
21     std::string sub3 = str3.substr(8,8);
22     std::string sub4 = str3.substr(10,2);
23     std::cout << "sub1:" << sub1 << std::endl;
24     std::cout << "sub2:" << sub2 << std::endl;
25     std::cout << "sub3:" << sub3 << std::endl;
26     std::cout << "sub4:" << sub4 << std::endl;
27     
28     
29     return 0;
30 }

 

posted on 2015-06-10 21:48  IT小不点  阅读(205)  评论(0编辑  收藏  举报