Skip to content

TRUEANGLE

BEAUTY AND PLAY

  • DOLLECT
  • Others
  • Configuration
  • AI
  • BLOG
  • ABOUT
    • ABOUT
    • Perception Style

How to write a program to find endianess of a machine ?

Posted byjeffrin July 11, 2014
#include <stdio.h>
#include <stdlib.h>

static inline int little_endian() {
int endian = 1;
return (0 == (*(char *)&endian));
}

int main (int argc, char **argv)
{

printf("This machine is ");
little_endian() ? printf("little") : printf("big");
printf(" endian\n");

exit(0);
}
Posted byjeffrinJuly 11, 2014Posted inC, operating system, Programming LanguagesTags: big indian, endianess, little endian

Post navigation

Previous Post Previous post:
How to write a program to modify a word using a bit mask ?
Next Post Next post:
Hacking with httping for simple speed study
July 2014
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  
« Jun   Aug »
TRUEANGLE, Proudly powered by WordPress.