基礎知識學習
M了個J 新浪微博:@M了個J,GITHUB:CODERMJLEE(歡迎★STAR點贊)
http://www.cnblogs.com/mjios/archive/2013/03/24/2977910.html
相關知識整理
輸出結構體數組中的內容
struct student
{
int num;
char *name;
char sex;
int age;
}stu[5]={
{1001,"lihua",'F',18},
{1002,"liuxing",'M',19},
{1003,"huangke",'F',19},
{1004,"fengshou",'F',19},
{1005,"Wangming",'M',18}
};
main()
{
int i;
struct student *ps;
//標題
printf("Num \tName\t\t\tSex\tAge\t\n");
/*用指針變量輸出結構體數組元素。*/
for(ps=stu;ps<stu+5;ps++)
printf("%d\t%-10s\t\t%c\t%d\t\n",ps->num,ps->name,ps->sex,ps->age);
system("pause");
}