我想在文本框中输入1001011 
然后程序把它当成2进制数 
请问该如何实现

解决方案 »

  1.   

    文本框只允许输入01,后面自己写一个转换函数
    好比:
    int length = strRes.GetLength();
    int n;
    for(int i = 0; i < length; i ++)
    {
        n += (strRes.getat(i) - '0') * pow(2.0, i);  //累加2的几次方
    }可能顺序不对,明白意思了,难道还不会写?
      

  2.   

    2进制和10进制都是数啊..在内存里存储的时候是一样的.显示的时候是以字符串显示,只有这个时候不同..
    所以atoi转换后,都一样的.
      

  3.   

    CString strText(_T("1001011"));
    DWORD dwVal = _tcstoul(strText, NULL, 2);
    strText.Format(_T("%d"), dwVal);
    AfxMessageBox(strText);