码迷,mamicode.com
首页 > 其他好文 > 详细

【转】CString类型互转 int

时间:2015-03-05 19:04:19      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

 原文网址:http://www.cnitblog.com/Hali/archive/2009/06/25/59632.html

CString类型的转换成int  
将字符转换为整数,可以使用atoi、_atoi64或atol。  

//CString aaa = "16" ; 
//int int_chage = atoi((lpcstr)aaa) ;  


而将数字转换为CString变量,可以使用CString的Format函数。如  
CString s;  
int i = 64;  
s.Format("%d", i)  
Format函数的功能很强,值得你研究一下。  
如果是使用char数组,也可以使用sprintf函数。

//CString ss="1212.12";  
//int temp=atoi(ss);  
//CString aa;  
//aa.Format("%d",temp);  


数字->字符串除了用CString::Format,还有FormatV、sprintf和不需要借助于Afx的itoa  

【转】CString类型互转 int

标签:

原文地址:http://www.cnblogs.com/wi100sh/p/4316414.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!