Mega Code Archive

 
Categories / C++ / String
 

Concatenate Using STL string

#include <string> #include <iostream> int main () {    using namespace std;    string strSample1 ("Hello");    string strSample2 (" String!");    // Concatenate    strSample1 += strSample2;    cout << strSample1 << endl << endl;    string strSample3 (" this is a test");    strSample1.append (strSample3);    cout << strSample1 << endl << endl;    const char* charPointer = "another test";    strSample1.append (charPointer);    cout << strSample1 << endl;    return 0; }