首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

把CString部类的数字相加减

2013-02-24 
把CString类型的数字相加减问题是有两CString字符数字,要对这两数字进行运算,菜鸟求指教,谢谢高手们!MFC中

把CString类型的数字相加减
问题是有两CString字符数字,要对这两数字进行运算,菜鸟求指教,谢谢高手们!
MFC中。 CString 运算 MFC
[解决办法]
百度 “CString 转int”
[解决办法]


#include <stdio.h>
#include <stdlib.h>
#include <afx.h>

int main(void)
{
    CString str1("1234"), str2("4321");
    int x,y;
    x= atoi((LPCTSTR)str1);
    y= atoi((LPCTSTR)str2);

    printf("x + y = %d\n",x+y);

 return 0;
   
}

[解决办法]
引用:
引用:#include <stdio.h>
#include <stdlib.h>
#include <afx.h>
int main(void)
{
    CString str1("1234"), str2("4321");
    int x,y;
    x= atoi((LPCTSTR)str1);
   ……



尝试下_wtoi。。。
[解决办法]
引用:
引用:#include <stdio.h>
有问题,  x= atoi((LPCTSTR)str1);这句在MFC中转换不了。


你得说错误原因啊。 

你加stdlib.h 头文件了吗

或者其他什么错误?

热点排行