I'm trying to figure out how to use a runtime-defined list in a C++ sprintf call on a run-defined string. The string will already have the tokens in there, I just need to somehow make the call for it to match as many args as it can in the string. Basically to compile the 4 calls below into a single call that would work for all of them, something along the lines of sprintf (buffer, "This is my string with args %i", myvec).
std::vector<int> myvec = {0, 1, 2, 3, 4};
char buffer [500];
sprintf (buffer, "This is my string with args %i", myvec[0], myvec[1], myvec[2], myvec[3], myvec[4]);
sprintf (buffer, "This is my string with args %i %i", myvec[0], myvec[1], myvec[2], myvec[3], myvec[4]);
sprintf (buffer, "This is my string with args %i %i %i", myvec[0], myvec[1], myvec[2], myvec[3], myvec[4]);
sprintf (buffer, "This is my string with args %i %i %i %i", myvec[0], myvec[1], myvec[2], myvec[3], myvec[4]);
I've spoken to my colleagues and they don't think anything like that exists, so I thought I'd put it out there. Any ideas?