How to convert an integer to a string portably?

后端 未结 2 1841
暖寄归人
暖寄归人 2021-01-18 06:30

I was looking for a way to convert an integer to a string in a portable manner (portable among at least Windows & Linux and x86 and x86_64) and I though itoa(X)

2条回答
  •  余生分开走
    2021-01-18 07:25

    Most often you just use printf("%d");

    http://en.wikipedia.org/wiki/Printf

    You can use sprintf if you need it in a buffer, but how often do you convert to a string and not write it to a file or output device?

提交回复
热议问题