2.4 输出结构体及cout使用方法
#include <iostream>
using namespace std;
#include <string.h>
typedef struct Student
{
int id;
char name[10];
char gender;
int age;
}*Stu;
int main() {
Student s[3] = {
{1,"qianshu",'f',22},
{2,"Totoro",'m',23},
{3,"haiqi",'f',20}
};
Stu p=s;
for(; p < s + 3; p++){
cout << p->id <<"\t" << p->name <<"\t" <<p->gender <<"\t" <<p->age <<"\n";
}
}

浙公网安备 33010602011771号