比如:XXX 是IP地址
LONG XXX = 0XE0001201;
CSTRING str;
str = 224.0.18.01;如何转化?

解决方案 »

  1.   

    xxx % 256^n n = 1 to 4
    如果你还搞不定,给我发个短消息。
    我把代码给你写出来
      

  2.   

    char buffer[200]
    ltoa(100,buffer,10)
    然后 就可以了
      

  3.   

    #include "math.h"LONG XXX = 0x20001201;  // 0xE0001201 为负数
    CString str1,str;
    for(int i=3;i>=0;i--)
    {
        LONG temp = pow(256,i);
        if(i>0)
           str.Format("%d.",XXX/temp);
       else
           str.Format("%d",XXX/temp);
       str1 = str1 + str;
       XXX = XXX % temp;
    }// 测试通过,显示:
    32.0.18.1