如何实现C++的double向CString的转换2

CStringlist::print(node*lh,node*lt){CStrings;node*n;n=lh;while(n->next!=lt){s+=n->p+"... CString list::print(node *lh,node *lt)
{
CString s;
node *n;
n=lh;
while(n->next!=lt)
{
s+=n->p+"*"+"x^"+n->e;
n=n->next;
}
return s;
}
这个函数出现错误 error C2111: pointer addition requires integral operand 我想转换为CString 这样就不会出现错误了吧
s.Format(_T("%f"),x);
不明白 那个n->e和n->p都是double
展开
 我来答
糖糖寳寳
推荐于2016-07-28 · TA获得超过6.4万个赞
知道大有可为答主
回答量:1.8万
采纳率:92%
帮助的人:4138万
展开全部
  可以使用atof、_gcvt。例子:
  #i nclude <stdlib.h>
  #i nclude <stdio.h>
  void main( void )
  {
  char *s; double x; int i; long l;
  s = " -2309.12E-15"; /* Test of atof */
  x = atof( s );
  printf( "atof test: ASCII string: %s/tfloat: %e/n", s, x );
  s = "7.8912654773d210"; /* Test of atof */
  x = atof( s );
  printf( "atof test: ASCII string: %s/tfloat: %e/n", s, x );
  s = " -9885 pigs"; /* Test of atoi */
  i = atoi( s );
  printf( "atoi test: ASCII string: %s/t/tinteger: %d/n", s, i );
  s = "98854 dollars"; /* Test of atol */
  l = atol( s );
  printf( "atol test: ASCII string: %s/t/tlong: %ld/n", s, l );
  }
  而将数字转换为CString变量,可以使用CString的Format函数。
  如:
  CString s;
  int i = 64;
  s.Format("%d", i)
百度网友acd2d0d
2007-05-19 · TA获得超过1488个赞
知道大有可为答主
回答量:1355
采纳率:100%
帮助的人:0
展开全部
CString s;
s.Format(_T("%f"),x);
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式