How to convert an integer to a string portably?

谁都会走 提交于 2019-12-01 17:22: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?

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!