結構體變量作函參

#include <iostream>
#include <string>
using namespace std;
struct student
{
int num;
string name;
float score[3];
};
int main()
{
void print(student);
student stu;
stu.num=110;
stu.name="陸巖";
stu.score[0]=99;
stu.score[1]=98;
stu.score[2]=97;
print(stu);
return 0;
}
void print(student stu)
{
cout<<stu.num<<" "<<stu.name<<" "<<stu.score[0]<<" "<<stu.score[1]<<" "<<stu.score[2]<<" "<<endl;
}
發佈了68 篇原創文章 · 獲贊 27 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章