* little endian versus big endian */
/*
* add: z z+1 z+2 z+3
* mem: 0D 0C 0B 0A //big endian
* mem: 0A 0B 0C 0D //little endian
* V = 0x0D0C0B0A
*/
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
int V = 0x0D0C0B0A;
char c = *( char *)(&V);
if (c == 0x0A || c == 0x0D) {
if (c == 0x0A)
printf( "little endian machine" );
else
printf( "big endian machine" );
} else
printf( "test error" );
putchar( '\n' );
exit(0);
}
/*
* add: z z+1 z+2 z+3
* mem: 0D 0C 0B 0A //big endian
* mem: 0A 0B 0C 0D //little endian
* V = 0x0D0C0B0A
*/
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
int V = 0x0D0C0B0A;
char c = *( char *)(&V);
if (c == 0x0A || c == 0x0D) {
if (c == 0x0A)
printf( "little endian machine" );
else
printf( "big endian machine" );
} else
printf( "test error" );
putchar( '\n' );
exit(0);
}