Saturday, September 17, 2011

Some function examples of STD string

example:



#include <iostream>

using namespace std;

string std_string;

int main()
{
cout << "STD String Test" << endl << endl;

std_string = "We wish you a merry Christmas and a Happy New Year!";
cout << "std_string = " << std_string << endl;
cout << "std_string.find(\"Christmas\") = " << std_string.find("Christmas") << endl;
cout << "std_string.substr(20, 9) = " << std_string.substr(20, 9) << endl;
cout << "std_string.insert(20, \"2011\") = " << std_string.insert(20, "2011 ") << endl;
cout << "std_string.erase(20, 5) = " << std_string.erase(20, 5) << endl;
cout << "std_string.replace(20, 6, \"X'\") = " << std_string.replace(20, 6, "X'") << endl;
return 0;
}




Some function examples of STD string




No comments:

Post a Comment