如何传递指向结构数组的指针 (函数参数)
2016-07-01 17:23
435 查看
就和普通指针一样使用,只不过它是结构体数组。
typedef struct Student
{
char name[10] ;
int age ;
}Student;
#define
LEN 10
//print all Student infomation
void fun(Student *pStu,int
len)
{
int i ;
for(i = 0 ;i <
len ;++i)
{
printf("%s\t%d",pStu[i].name,pStu[i].age) ;
}
}
int main ()
{
Student stu[LEN] ;
fun(stu,LEN) ;
}
希望能帮助到你
就和普通指针一样使用,只不过它是结构体数组。
typedef struct Student
{
char name[10] ;
int age ;
}Student;
#define
LEN 10
//print all Student infomation
void fun(Student *pStu,int
len)
{
int i ;
for(i = 0 ;i <
len ;++i)
{
printf("%s\t%d",pStu[i].name,pStu[i].age) ;
}
}
int main ()
{
Student stu[LEN] ;
fun(stu,LEN) ;
}
希望能帮助到你
相关文章推荐
- Spring使用proxool连接池 管理数据源
- emmc挂载,分区及格式化
- MapReduce自定义输入格式
- markdown的图片外链
- C++ string类的实现
- 从apache mod_php到php-fpm[转]
- Google Protocol Buffer 的使用和原理
- git学习笔记(一)
- jmeter 3.0安装配置
- nodejs系列学习:http请求html/css/js-----(二)
- 带有安全认证的webservice
- poj1325
- Kth Largest Element in an Array
- 简单的CSS样板
- vc++ 6.0转vs2010出现的问题
- 常用Oracle问题诊断sql脚本
- 从源码角度彻底分析layout_weight使用
- gcc/g++
- 根据PID号判断所属的容器
- 怎样通过后台控制前台<input>可编辑或不可编辑