* Author: S. Piccardi
* May. 2003
*
- * $Id: endian.c,v 1.2 2003/08/16 17:36:03 piccardi Exp $
+ * $Id: endian.c,v 1.3 2003/08/16 18:11:24 piccardi Exp $
*
***************************************************************/
#include <stdio.h>
*/
int i, val;
char buf[sizeof(int)];
- char * char_ptr;
int * int_ptr;
val = 0xABCDEF01; /* endianess magic number */
- int_ptr = (int *) buf;
+ int_ptr = (int *) buf;
*int_ptr = val;
- char_ptr = (char *) &val;
+ val = 0;
for (i=0; i<sizeof(int); i++) {
- char_ptr[i] = buf[i];
+ val = (val<<8) + buf[i];
printf("i=%d, val=%x\n", i, buf[i]);
}
printf("Value %x\n", val);