I really liked the answer in sprintf in C ++? but he is still not quite what I am looking for.
I want to create a constant string with placeholders like
const std::string LOGIN_URL = "%s://%s/chronicle/spring/api/logout";
and then create a string with removable parameters, for example:
sprintf(url, LOGIN_URL, protocol, server);
but I really want to stay away from C lines if I can help.
The stringbuilder () method requires me to break my constant lines and collect them when I want to use them. This is a good approach, but what I want to do is more neat.
source
share