//
// main.cpp
// 结构体指针作为形参
//
// Created by geek on 15/9/1.
// Copyright (c) 2015年 geek. All rights reserved.
//
#include <iostream>
using namespace std;
struct student{
int num;
char name[20];
float score;
};
void print(student *p){
cout<<p->num<<" "<<p->name<<" "<<p->score<<endl;
}
int main(int argc, const char * argv[]) {
student stu[3]={{1,"lbp",100},{2,"ckb",90},{3,"ycl",93}};
for(int i=0;i<3;++i){
print(&stu[i]);
}
return 0;
}
转载于:https://my.oschina.net/u/1778933/blog/500197