有代码实现:
int checkCPU(){
union{
int a;
char c;
}
a = 1;
return (c == 1);
}
int main(){
int t = 0;
t = checkCPU();
if(t == 1){
printf("CPU is little-endian.");
}else{
printf("CPU is big-endian.");
return 0;
}
}
有代码实现:
int checkCPU(){
union{
int a;
char c;
}
a = 1;
return (c == 1);
}
int main(){
int t = 0;
t = checkCPU();
if(t == 1){
printf("CPU is little-endian.");
}else{
printf("CPU is big-endian.");
return 0;
}
}