Is it possible to format std::string
passing a set of arguments?
Currently I am formatting the string this way:
string helloString = "Hello %s and %s";
vector<string> tokens; //initialized vector of strings
const char* helloStringArr = helloString.c_str();
char output[1000];
sprintf_s(output, 1000, helloStringArr, tokens.at(0).c_str(), tokens.at(1).c_str());
But the size of the vector is determined at runtime. Is there any similar function to sprintf_s
which takes a collection of arguments and formats a std::string/char*? My development environment is MS Visual C++ 2010 Express.
EDIT: I would like to achieve something similar:
sprintf_s(output, 1000, helloStringArr, tokens);