I'm trying to create a simple template engine, an engine that takes a pattern and some variable and produces a string output. This is the idea:
const char * pattern = ReadPattern(); // pattern is like "%s in %s ft"
vector<const char *> variable = ReadVariable(); // variable is like "6", "5".
How can I call printf function with them?
Ideally I can do printf(pattern, variable[0], variable[1]);
But because both pattern and variable are not known until runtime,
I don't even know the number of variable.
To my understanding, constructing a va_list programmingly is a not portable.
Please help, Thank you!