CString str="000123";
CString temp;如何让temp等于"123" ?

解决方案 »

  1.   

    参考一下,删除字符串中所有的空格void TrimAllSpace(CString &strText)
    {
    CString strLeft = _T("");
    CString strRight = _T(""); int nPos = strText.Find(_T(" "));
    while (nPos != -1)
    {
    strLeft = strText.Left(nPos);
    strRight = strText.Right(strText.GetLength()-nPos-1);
    strText = strLeft + strRight; nPos = strText.Find(_T(" "));
    }}
      

  2.   

    CString str="000123";
    CString temp;
    long    iTemp;iTemp = _ttol(str);
    temp.Format(_T("%ld") , iTemp);
      

  3.   

    先找到第一个不为0的字符的下标-〉p
    后tmp = str.Left(p)
      

  4.   

    这个容易呀。
    temp.TrimLeft("0");
      

  5.   

    CString str="000123";
    CString temp;
    temp = str.TrimLeft('0');
    哈哈
      

  6.   

    int nStart = 0;
    CString str = "000123";
    while(1)
    {
    if(str.GetAt(nStart) != '0')
    {
    CString temp = str.Mid(nStart,str.GetLength()-nStart);
    MessageBox(temp);
    break;
    }
    nStart++;

    }
      

  7.   

    //try followCString str = "000123";
    CString tmp = "";
    int n = atoi(str);
    tmp.Format("%d",n);
      

  8.   

    都怎么学的,这么常用的一些标准函数都没有几个人知道。
    经常看到一些很简单的问题其实就是一个标准函数,但多数人竟然没有想到。
    实现某一个功能的方法很多,但如果有了标准的函数来实现,那这个功能我们还需要自己写函数来实现吗?hdsunwind(太阳风) 的方法是理所当然的解决方法。
    也可以用 atoi,atol之类的函数代替。