您的位置:首页 > 编程语言 > C语言/C++

c语言结构体保存并输出学生信息

2016-06-02 22:04 267 查看
最近在学习数据结构,巩固下c语言。

#include<stdio.h>
/*定义结构体student并设置别名stud*/

/*typedef struct student{
int num;
char *name;
int score;
}stud;
*/

/*同上面4行代码*/
struct student{
int num;
char *name;
int score;
};
typedef struct student stud;

stud stu[3] = {
{1026,"Jack",100},
{1028,"Michael",80},
{1030,"Nice",30}
};

int main()
{
int i;
for(i=0;i<3;i++)
{
printf("%d,Name:%s,score:%d\n",stu[i].num,stu[i].name,stu[i].score);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: