if(iB<0 || iB>4)
{
iB=4;
}我改成了
if((UINT)iB > 4)
{
iB=4;
}

解决方案 »

  1.   

    strBaseText = _T("");
    for (int i=0;i<iBit;i++)
    {
    strBaseText += _T("0");
    }感觉这样,如果要得到100个0的串的话,效率不高,但也懒得想算法了,所以把这事儿交给MFC吧
    CString strTemp;
    strTemp.Format(_T("%%0%d"), iBit);
    strBaseText.Format((LPTSTR)(LPCTSTR)strTemp, 0);
      

  2.   

    我老是在纠结小问题,这可怎么办
    strBaseText永远是N个0+1个char的字符串,但需要大写,直接这样就可以了
    SetWindowText(strBaseText.MakeUpper());
    但我觉得,为了让一个字符大写,却要让MakeUpper遍历整个字符串,不划算,所以自己写了个
    MakeUpper(char)的函数
    strBaseText+MakeUpper(s)
      

  3.   

    哦,看来我还是小看了原来的自己,
    MakeUpper不但将字符变大写,而且判断了非法字符,因为表示方向的只有ewns
      

  4.   

    感觉这样,如果要得到100个0的串的话,效率不高,但也懒得想算法了,所以把这事儿交给MFC吧CString strText(_T(""));
    int nValue = 0;
    strText.Format(_T("%0100d"), nValue);
    AfxMessageBox(strText);
      

  5.   

    CString strTemp;
    strTemp.Format(_T("%%0%dd"), iBit);
    strBaseText.Format((LPTSTR)(LPCTSTR)strTemp, 0);
      

  6.   

    CString strText(_T(""));
    int nValue = 0;
    int nIndex = 10;
    CString strIndex(_T(""));
    strIndex.Format(_T("%%0%dd"),nIndex);
    AfxMessageBox(strIndex); // %05
    strText.Format(strIndex, nValue);
    AfxMessageBox(strText);
      

  7.   

    int比较安全啊
    iB = ((iB >= 0) && (iB <= 4)) ? iB : 4;
      

  8.   

    iB是个很大的正数,所以它大于4,所以同时会进if