C++ 函如何调用结构体数组
函数怎么把结构体数组作形参,并且能调用 ,请给出一个详细的实例 谢谢
2011-11-12 15:22
程序代码:#include<iostream>
#include<string>
using namespace std;
struct Student{
int num;
string name;
};
void print(Student stu[],int n);
int main()
{
Student stu[2]={
{1000,"aaa"},
{1001,"bbb"}};
print(stu,2);
return 0;
}
void print(Student stu[],int n)
{
for(int i=0;i<n;i++)
{
cout<<stu[i].num<<'\t'<<stu[i].name<<endl;
}
}
2011-11-12 17:23
2011-11-12 21:18
2011-11-13 15:03