2011年3月17日 星期四

typedef 用法 (struct)


struct Student {
char name[32];
int number;
};

要使用時就必需宣告為


struct Student mystudent = {"John", 10};


我們可以為它加上別名


typedef struct {
char name[32];
int number;
} Student;


這樣就可以直接有一個Student型別可以使用


Student mystudent = {"John", 10};

沒有留言:

張貼留言