X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2Fendian.c;h=e7dbe0f36957f66afb65f2e9b90b133e67af18b6;hp=0505b365ccfeeb00d5546bbe7708fcc91ec17805;hb=HEAD;hpb=17f2a5e09bfbb9bd8b897de4fbf701fd1dc4e861 diff --git a/sources/endian.c b/sources/endian.c index 0505b36..e7dbe0f 100644 --- a/sources/endian.c +++ b/sources/endian.c @@ -23,12 +23,9 @@ * Author: S. Piccardi * May. 2003 * - * $Id: endian.c,v 1.4 2003/08/16 18:22:25 piccardi Exp $ - * ***************************************************************/ -#include -int main(int argc, char *argv[]) +int endian(void) { /* * Variables definition @@ -36,11 +33,8 @@ int main(int argc, char *argv[]) short magic, test; char * ptr; - magic = 0xABCD; /* endianess magic number */ - ptr = (char *) &magic; - printf("Upper = %x\n", ptr[1]); - printf("Lower = %x\n", ptr[0]); - test = (ptr[1]<<8) + (ptr[0]&0xFF); - printf("magic=%x, test=%x\n", magic, test); - return (magic == test); + magic = 0xABCD; /* endianess magic number */ + ptr = (char *) &magic; + test = (ptr[1]<<8) + (ptr[0]&0xFF); /* build value byte by byte */ + return (magic == test); /* if the same is little endian */ }