Those Simple "Source Programming Questions" Thread...
I hate having really small simple questions that are hard to google. They're too small to make your own thread about, but they're too annoying to find the answer to without asking for help. It be nice if there was a nice relaxing place where people could ask quick questions.
Hopefully this thread will become the place to ask such questions.
and I've got two to start off with.
In C++, is there a standard way to format a string (printf style) but instead of printing it to console, have it return a string or char array?
Something like the fictional "format" function here.
coolText would hold "the magic number is 5!!"
My other question is what does it mean when a struct is initialized with {0};? I sometimes see code like...
Hopefully this thread will become the place to ask such questions.
and I've got two to start off with.
In C++, is there a standard way to format a string (printf style) but instead of printing it to console, have it return a string or char array?
Something like the fictional "format" function here.
- Code: Select all
int number = 5;
std::string coolText = format("the magic number is %i!!", number);
coolText would hold "the magic number is 5!!"
My other question is what does it mean when a struct is initialized with {0};? I sometimes see code like...
- Code: Select all
CoolStruct myCoolStruct = {0};