0

after vising cplusplus site and checking my book i havent found any example
or explanation... so here it is:

i have a function called "string stringreturn()"
now inside i have INT LIFE , and INT NUM
i would like to return the following

"blabla bla (INT LIFE VALUE) bla bla (INT NUM VALUE ) blabla (SOME CONST VALUE)"
i tried the following which didnt work

return( "blabla" , LIFE, "blalb" , NUM, CONSTTHING);

any tips ? the function is called like this

string newstring = stringreturn();
thanks!

EDIT
P.S
i also tried using :
string newOne= "blablabla ";
newOne+= LIFE;
newOne+= " blabla";
etc

Edited by Despairy: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by jwenting
1

Send everything you want to output into a string stream(#include <sstream>).

std::stringstream ss;
ss << "My hero has " << LIFE << "life and " << bla bla bla;

return ss.str();
0

edit: ok i did it , thanks alot :)

Edited by Despairy: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.