Last active
June 23, 2016 19:42
-
-
Save ilpropheta/404d346da720a364aabc29bcbeb5ae7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string res(char_needed, 0); | |
sprintf(res.data(), "%d", intNumber); |
Yeah, it's definitely better, even if res is actually filled with zeros so successive operations on the string should take this information into account.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you'd need to resize afterwards:
string res(char_needed); res.resize(sprintf(res.data(), "%d", intNumber));