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

Recommended Answers

All 3 Replies

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();

edit: ok i did it , thanks alot :)

is it still open in a debugger somewhere maybe?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.