슈개's IT/Engineer Room
Source 포함: 리틀엔디안 빅엔디안 확인하는 방법
슈개
2021. 1. 23. 10:47
반응형
Source: 리틀엔디안 빅엔디안 확인하는 소스
나의 본인PC가 리틀엔디안(Little Endian)인지? 빅엔디안(Big Endian)인지? 확인하는 소스입니다.
2가지중 한가지만 사용해도 무관합니다.
1번째 소스: 아래 소스만으로도 확인가능합니다.
#include <stdio.h>
#include <stdlib.h>
int Test_Little_Endian();
int main()
{
printf("This program is intended to determine whether this computer is little endian or not.\n\n");
printf("Result: ");
if(Test_Little_Endian())
{
printf("This pc is on the little endian.\n");
}
else
{
printf("This pc is on the big endian.\n");
}
getchar();
return 0;
}
int Test_Little_Endian()
{
unsigned num = 0x00FF;
return (*(unsigned char*)&num==0xFF);
}
반응형