How to convert an integer to a string portably?

后端 未结 2 1861
暖寄归人
暖寄归人 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:20

    If you aren't doing this terribly often, how about a runtime library routine that writes a few numbers to memory, analyzes the results and stores an encoding type? From then on you just switch on your "encoding type" to select which conversion routine to use.

提交回复
热议问题