M
Mike Copeland
Is there a more convenient/simple way to specify string formatting
than the following?
ostringstream ossw;
string str;
long nts;
ossw.str(""), ossw << left << setw(12) << nts, str = ossw.str();
I have much of this type of code, with many setw() calls and various
right and left modifiers. It would be a lot simpler to have something
like "setwleft(12)" or something like that to reduce my code. (It might
execute faster, too...)
Of course, it was (to me) much simpler to use C-style formatting
(sprintf, etc.), but having to use ".c_str()" for string data is messy
and error-prone (when I forget to add it).
Are there other options for string formatting? Please advise. TIA
than the following?
ostringstream ossw;
string str;
long nts;
ossw.str(""), ossw << left << setw(12) << nts, str = ossw.str();
I have much of this type of code, with many setw() calls and various
right and left modifiers. It would be a lot simpler to have something
like "setwleft(12)" or something like that to reduce my code. (It might
execute faster, too...)
Of course, it was (to me) much simpler to use C-style formatting
(sprintf, etc.), but having to use ".c_str()" for string data is messy
and error-prone (when I forget to add it).
Are there other options for string formatting? Please advise. TIA