自考新教材--p53

源程序:

#include <iostream>

#include <string>

using namespace std;

 

int main()

{

string str;

if (str.empty())

cout << "str is NULL." << ",length=" << str.length() << endl;

else

cout << "str is not NULL." << endl;

str = str.append("abcdefg");

cout << "str is" << str << ",size=" << str.size() << endl;

const char *p = str.c_str();

cout << "p=" << p << endl;

cout << "find:" << str.find("de",0)<<endl;

cout << "find:" << str.find("de", 4) << endl;

string str1 = str.insert(4,"123");

cout << str1 << endl;

system("pause");

return 0;

}

运行结果:

posted @ 2019-12-02 19:17  bobo哥  阅读(116)  评论(0编辑  收藏  举报