Latest algorithm dictionary in C language (written by Haruhiko Okumura / 1991 first edition Gijutsu-Hyoronsha: 16 pages)
The order of high-order bytes and low-order bytes is commonly called endian. Little endian is the youngest address in memory, and big endian is the opposite.
Source: http://www.ertl.jp/~takayuki/readings/info/no05.html
endian.c
/*endianness endianness*/
/*Examine the endianness of int type*/
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i = 1;
if(*((char *)&i))
{
printf("little-endian\n");
}
//i char*Cast to int-True if the value obtained by shifting the pointer reference destination by one size is ≠ 0
else if(*((char *)&i + (sizeof(int) - 1)))
{
printf("big-endian\n");
}
else
{
printf("unknown\n");
}
return EXIT_SUCCESS;
}
The result was that it was little endian.
result.txt(Any)
Success #stdin #stdout 0s 4380KB
little-endian
Recommended Posts