C++判断本机的字节序的方法研究(转)

bool isBigEnding(){
    int i = 1;
    return ((char)i) == 1;
}

bool isBigEnding(){
    union {
        int i;
        char c;
    }x={1};
    return x.c == 1;
}

bool isBigEnding{
    union {
        int i ;
        struct {
            unsigned short int b : 8;
        }bit;
    }x={1};
    return x.bit.b == 1;
}

Monthly Archives

Pages

Powered by Movable Type 7.7.2

About this Entry

This page contains a single entry by Cnangel published on July 16, 2008 12:37 PM.

推荐远程桌面工具VNC was the previous entry in this blog.

40个技巧优化你的PHP代码 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.