|
shivan2k 님이 쓰신 글 :
: #include<stdio.h>
:
: typedef struct w_byte
: {
: unsigned byte0: 8;
: unsigned byte1: 8;
: unsigned byte2: 8;
: } temp1;
:
: typedef struct flag
: {
: unsigned bit_a: 1;
: unsigned bit_b: 1;
: unsigned bit_c: 1;
: } temp2;
:
: typedef union word
: {
: int x;
: temp1 y;
: temp2 z;
: } temp3;
:
: void main()
: {
: temp3 test1;
: test1.x=1;
: test1.y.byte0='a';
: test1.z.bit_a=1;
: printf("test1.x =%d\n",test1.x);
: printf("test1.y.byte0 =%d\n",test1.y.byte0);
: printf("test1.bit_a =%d\n",test1.z.bit_a);
: }
:
: 다 알려달라고 해서 답변이 없는거 같아서요...
: typedef 는 그냥 데이터형 정의 하는것이죠...
: unsigned 은 음수가 않나오게 하는것이고
:
: union 은 공유체로 기억장소를 공유(?) 덮어쓰기같은거(?) 나중값을 기억...(?맞나요?)
:
: temp3 에서 int x; temp1 y; temp2 z; 라고 정했는데 거기 부분이 공유체가 사용된곳이니깐
: test1.x=1
: a 가 아스키코드 10진(?) 이게 97 이죠...???
:
:
: 결과는 97,97,1 이라고 나오는데
:
: test1.x 가 왜 97이 나오죠??? 그럼 아스키 값이 아니라는것같은데 --;...
:
: 조금만 알려주세여
|