我得到一个数字比如2,
如何把他变成字符串“2”
谢谢

解决方案 »

  1.   

    CString s;
    s.Format("%d",2);
      

  2.   

    最简单的是使用CString类;CString strInt;
    strInt.Format("%d",2);
      

  3.   

    int num=2;
    char *ch=new char[4];
    itoa(num,ch,10);
      

  4.   

    数字转换成字符串函数:CRT 的: sprintf swprintfWIN32 的 wsprintf 例如这样:
    char s[2];
    sprintf(s, "%i", 2);这样, char 数组 s, 就包含 '2' 了够细没?
      

  5.   

    还有c的标准函数
    atoi()
      

  6.   

    按来总结一下:1,atoi()
    2,char* pCh="1234";
    int num=pCh[i]-'0';//i为字符串中的索引号