How in c++ create message similar to snprintf and just change value in message? -


how can create message similar snprintf ( can have generic text %d integer , when need show in sprintf connect parameter), avoid concatenation? (i need create result string you need more %d coins, @ moment doing on bad way concatenate , return value 'you need more' + some_stringified_value + 'coins')

the "canonical" c++ way use stringstream, this:

std::string somefunc(int number) {   std::stringstream ss;   ss << "you need " << number << " more coins";   std::string str = ss.str();   return str; } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -