블로그 이미지
송시혁

calendar

1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Notice

Tag

Recent Post

Recent Comment

Recent Trackback

Archive




리눅스에서는 줄여서 왼쪽과 같이 쓴다. 원래는 오른쪽이 원본 명령어이다.

리눅스: u_int32_t  = unsigned int 32 bit typedef

           u_int8_t   = unsigned int 8 bit typedef


#include <stdio.h>
struct SMART
{
  int a;
  short a11;
  char a1;
  
  char a2;
  
  int b;
  int c;
  short c1;
  char c2;  
  int d;

}; //구조체에도 끝에 ;을 붙여야한다.

int main()
{
  struct SMART test;
  struct SMART ak;
  test.a = 100;
  test.b = 200;
  test.c = 300;
  printf("a변수 %d\n", test.a); 
  printf("b변수 %d\n", test.b);
  printf("c변수 %d\n", test.c);
  printf("구조체 크기: %d\n"sizeof(test));
  printf("%d\n"sizeof(ak));

  return 0;
}

1.함수 위에 구조체 선언.
2.main()함수내부에 struct SMART test;
  구조체 안에 int a,b,c,d....등이 선언되었다.
3.main()함수 안에 변수에 타입에 의해 크기를 가진다.
  예를 들어 int a,b,c세개가 선언되면 12바이트의 크기를 가진다.
4. 그러나 변수사이사에 새로운 변수를 집어넣어 크기를 확인해본다.
   변수의 위치의 따라 크기가 다르다. 아래의 예를 주목한다.






posted by 송시혁