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";
	}

}
posted @ 2022-03-17 20:58  千树line  阅读(822)  评论(0)    收藏  举报