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;
}

Categories

| | 评论(0)

发表评论

August 2012

      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

关于此日记

此日记由 Cnangel 发表于 July 16, 2008 12:37 PM

此Blog上的上一篇日记推荐远程桌面工具VNC

此Blog上的下一篇日记40个技巧优化你的PHP代码

首页归档页可以看到最新的日记和所有日记。

归档

Powered by Movable Type 5.14-en