Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C Determine endianess

Name: Anonymous 2007-06-27 10:43 ID:Uo4E/xRf

I wrote it and i edited wikipedias article which had a terrible code and added mine, but i'm still not sure about my code, is it SCALABLE ENOUGH?

#include <stdio.h>

int main() {

        union {
                int s;
                char c[sizeof(int)];
        } un;
        const char *endianess[[] = { "big endian", "little endian" };

        un.s = (~(int)0) ^ (~(char)0);
        puts(endianess[!un.c[0]]);

        return 0;
}

Name: Anonymous 2007-06-30 14:00 ID:zQsnOZDR

>>33
PROTIP: NO SUCH DIFFERENCE EXISTS.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List