I currently have a function that I want to return a single string, but I want it to return all elements of a string array in a single string which the function can return. Any advice is appreciated.
Asked
Active
Viewed 76 times
-1
-
Use `std::stringstream` from `#include
` to concatenate your strings. – zneak May 05 '14 at 03:44 -
http://stackoverflow.com/questions/5689003/how-to-implode-a-vector-of-strings-into-a-string-the-elegant-way – Darius Houle May 05 '14 at 03:45
-
3Please show what, if any, code you have tried. – R Sahu May 05 '14 at 03:45
1 Answers
0
You can just do like this:
string f()
{
string s1 ="Hello ";
string s2 = "world!";
stringstream ss;
ss<< s1;
ss<< s2;
return ss.str();
}

Rakib
- 7,435
- 7
- 29
- 45