is there a way of adding a phrase to a string together to make one?
i already know you can add two strings togethor.
sort of like this
Code:cout<<"Path: "; cin>>filename; string dir = "dir " + filename;
is there a way of adding a phrase to a string together to make one?
i already know you can add two strings togethor.
sort of like this
Code:cout<<"Path: "; cin>>filename; string dir = "dir " + filename;
Last edited by Led4urhead123; 07-10-2008 at 02:58 PM.
If inserting strings or characters to the front or back is not sufficient, you can always use one of the insert member functions, like this version which uses iterators:
Choose a function which you can understand and will do the job you need to do.Code:#include <iostream> #include <string> int main () { std::string part[] = {"mystuff", "/path/to/"}; part[0].insert(part[0].begin() + 2, part[1].begin(), part[1].end()); std::cout<<part[0]<<'\n'; }
Are you having a problem? If filename is a string then the posted code should compile fine.