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; }
相关文章推荐
- Inheritance继承
- C++ placement new操作符
- 二叉树的创建与前序遍历(递归方式)
- C++中,a++、a+=1、a=a+1、++a 有什么区别?以及效率问题
- C语言练习篇-6利用指针通过形参传值给主调函数
- 【转载】C++资源之不完全导引
- C++模板小例
- 生成窗口最大值数组
- Q1009 FatMouse' Trade C++
- C++走向远洋——61(项目一、排序函数模板)
- C++走向远洋——60(十四周阅读程序、STL中的简单容器和迭代器)
- c++incline函数
- c++和java的区别
- 【C/C++】产生随机数
- 【C++】 ofstream列对齐和设置小数点精度
- C++的异常处理 & Objc的异常处理
- C++走向远洋——60(项目四、立体类族共有的抽象类)
- Windows7下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
- 参考小白书上用c++采用结构体重载的大数类模版
- C++ Primer 第五版 部分课后题答案