C++ examples for STL:string
Use string member function substr
#include <iostream> #include <string> using namespace std; int main() //from w ww . ja v a2s.co m { string s1( "happy test test test test " ); string s2( " birthday test test test test " ); string s3; cout << "The substring of s1 starting at location 0 for\n" << "14 characters, s1.substr(0, 14), is:\n" << s1.substr( 0, 14 ) << "\n\n"; }