您的位置:首页 > 其它

字符串数值转换问题总结

2014-09-05 15:38 302 查看
1.数字转字符串

#include<stdlib.h>
#include<stdio.h>
int main()
{
	int number=16;
	char string[25]="";
	 sprintf(string, "%06d", number);  
	printf("integer=%dstring=%s\n",number,string);
	return 0;
}


2.字符串转换数字

atoi

atof

3.浮点数等需要注意进行比较的时候需要在一定的精度内比较,不用用==来比较

参考:

http://www.uml.org.cn/c++/200908315.asp C++中的数据类型转换方法

http://blog.sina.com.cn/s/blog_4c8a2a870100qgq7.html

http://sealbird.iteye.com/blog/866701

http://blog.itpub.net/14766028/viewspace-703264/

http://www.cnblogs.com/lidabo/archive/2012/07/10/2584706.html

http://www.jb51.net/article/36935.htm 转换过程中精度的问题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: