3 * Copyright (C) 2003 Simone Piccardi
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /***************************************************************
21 * routine endian: routine to detect endianess
26 * $Id: endian.c,v 1.2 2003/08/16 17:36:03 piccardi Exp $
28 ***************************************************************/
31 int main(int argc, char *argv[])
34 * Variables definition
37 char buf[sizeof(int)];
41 val = 0xABCDEF01; /* endianess magic number */
42 int_ptr = (int *) buf;
44 char_ptr = (char *) &val;
45 for (i=0; i<sizeof(int); i++) {
47 printf("i=%d, val=%x\n", i, buf[i]);
49 printf("Value %x\n", val);