author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 05 Mar 2010 22:16:39 +0100 | |
changeset 118 | 17dff2c6fc88 |
parent 106 | a540a842ddef |
permissions | -rw-r--r-- |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
1 |
/** |
77 | 2 |
* endian.c |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
5 |
||
6 |
#include <stdio.h> |
|
7 |
#include <stdlib.h> |
|
8 |
||
9 |
int endian () |
|
10 |
{ |
|
11 |
unsigned short word = 0x1234; |
|
12 |
unsigned char *p = (unsigned char *)&word; |
|
13 |
||
106
a540a842ddef
Endian Check simplified...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
14 |
return (p[0] == 0x34); |
0 | 15 |
} |
16 |
||
17 |
int main (int argc, char **argv) |
|
18 |
{ |
|
106
a540a842ddef
Endian Check simplified...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
77
diff
changeset
|
19 |
printf ("%s Endian System\n", (endian ())? "Little" : "Big"); |
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
20 |
|
0 | 21 |
return EXIT_SUCCESS; |
22 |
} |