메모리 점유의 리틀 엔디안 값 확인
This commit is contained in:
28
Practice_03/p03-4.c
Normal file
28
Practice_03/p03-4.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void printBinary(unsigned char byte);
|
||||
|
||||
int main(void){
|
||||
int a = 10;
|
||||
unsigned char *p = (unsigned char*)&a;
|
||||
|
||||
printf("int a = %d\n", a);
|
||||
printf("메모리 저장 순서 : \n");
|
||||
|
||||
for(int i = 0; i < sizeof(a); i++){
|
||||
printf("주소 %p : 0x%02X", (p + i), p[i]);
|
||||
printBinary(p[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printBinary(unsigned char byte){
|
||||
printf(" --> ");
|
||||
for(int i = 7; i >= 0; i--){
|
||||
printf("%d", (byte >> i) & 1);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
Reference in New Issue
Block a user