Reti costruito secondo esercizio sulle architetture big e little endian
This commit is contained in:
21
2.little_big_endian/my_architecture.c
Normal file
21
2.little_big_endian/my_architecture.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int main (int index, char** in_data){
|
||||
|
||||
short data = 0x0102;
|
||||
char* datacp = (char*)&data;
|
||||
if (*datacp == 0x01 && *(datacp+1)==0x02){
|
||||
printf("Big Endian\n");
|
||||
}else{
|
||||
if(*datacp == 0x02 && *(datacp+1)==0x01){
|
||||
printf("Little Endian\n");
|
||||
}else{
|
||||
printf("Unknow\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user