Convert a number to a string with specified length in C++

后端 未结 8 1346
情深已故
情深已故 2020-12-04 23:36

I have some numbers of different length (like 1, 999, 76492, so on) and I want to convert them all to strings with a common length (for example, if the length is 6, then tho

8条回答
  •  情歌与酒
    2020-12-05 00:07

    stringstream will do (as xtofl pointed out). Boost format is a more convenient replacement for snprintf.

提交回复
热议问题