You can make a function almost similar to WriteLine from c#:
void WriteLine(string const &outstr, ...) {
va_list placeholder;
va_start(placeholder, outstr);
bool found = false;
for (string::const_iterator it = outstr.begin(); it != outstr.end(); ++it) {
switch(*it) {
case '{':
found = true;
continue;
case '}':
found = false;
continue;
default:
if (found) printf("%s", va_arg(placeholder, char *));
else putchar(*it);
}
}
putchar('\n');
va_end(placeholder);
}
Call it with similar arguements:
WriteLine("My fav place in the world is {0}, and it has a lot of {1} in it", "Russia", "Mountains");
Output:
My fav place in the world is Russia, and it has a lot of Mountains in it
The function is of course not perfect because the System.Console.WriteLine() function from c# can have the arguements not in order and still place the correct strings in the right place in the full string. This can be solved by first placing all the arguements in an array and accessing the index of the array