VC++中怎么将CString与double互相转换!
比如CString的a=“123”,b=“456”,把它们转换成double型,相加后结果再转成CString型!...
比如CString的a=“123”,b=“456”,把它们转换成double型,相加后结果再转成CString型!
展开
2个回答
2013-08-07
展开全部
#include "stdafx.h"
#include "atlstr.h"
int main()
{
CString a="123";
CString b="456";
double k;
k= _wtof(a.GetBuffer(a.GetLength()));
double k1;
k1= _wtof(b.GetBuffer(b.GetLength()));
double sum1=k+k1;
CString sum;
sum.Format(_T("%f"),sum1);
printf("%s",sum);
getchar();
getchar();
return 0;
}
#include "atlstr.h"
int main()
{
CString a="123";
CString b="456";
double k;
k= _wtof(a.GetBuffer(a.GetLength()));
double k1;
k1= _wtof(b.GetBuffer(b.GetLength()));
double sum1=k+k1;
CString sum;
sum.Format(_T("%f"),sum1);
printf("%s",sum);
getchar();
getchar();
return 0;
}
推荐于2017-10-07
展开全部
string aa = "123";
string bb = "123";
int cc = atoi(aa.c_str()); //atoi
string bb = "123";
int cc = atoi(aa.c_str()); //atoi
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询