structとtypedef structの違い
1470 ワード
struct{
} 1, 2;
( 1, 2) 2 ?
,
。
struct list{
int a;
char c;
stuct list *next;
};( )
struct list ;struct 。 :
:struct list student;
struct list ?
struct list ;
struct list{
int a;
char c;
stuct list *next;
};
typedef struct list A;
A student; struct list student;
。
typedef struct list{
int a;
char c;
struct list *next;
}A;
//////////////////////////////////////////////////////////////////
(1) struct{ int x; int y; }test1;
, test1,
test1.x test1.y 。
(2) struct test {int x; int y; }test1;
, test1,
test1.x test1.y 。
1 , test
(3)
typedef struct test
{int x; int y; // ,
}text1,text2;
( ) text1 text2
, :
text1 test1;
test1.x test1.y
text2 test1;
test1.x test1.y
(4)type struct {int x; int y; }test1;
。
typedef ... 。
(3) , :
test1 my_st;
my_st.x my_st.y