我看有的代码是这样的
CString str("123");
int i = atoi(str.GetBuffer(10));
str.Release.Buffer();但为何不直接这样呢?
CString str("123");
int i = atoi(str);

解决方案 »

  1.   

    你写错了吧上面应该这样:CString str("123");
    int i = atoi(str.GetBuffer(str.GetLength()));
    由于没有赋值操作下面一句也不需要的
    str.ReleaseBuffer();
    =====
    应该是没什么区别吧,atoi(str);其中的str也会被类型转换为const char *  ,而str.GetBuffer(str.GetLength())的值便是char *
      

  2.   

    我就是不太明白啊,我在程序里用的是
    CString str("123");
    int i = atoi(str);此段程序在2000下没问题,但在XP下有的机器不对,有的机器会出错
      

  3.   

    哦,应该是:
    我就是不太明白啊,我在程序里用的是
    CString str("123");
    int i = atoi(str);此段程序在2000下没问题,但在XP下有的机器对,有的机器不对