#include <iostream>
#include <fstream>
using namespace std;
struct student{
char name[20];
int age;
};
const int sz = 3;
int main()
{
student stu[sz];
ifstream stufile("stu.txt");
for (int i=0; i<sz; i++)
stufile >> stu[i].name >> stu[i].age;
stufile.close();
for (int i=0; i<sz; i++)
cout << stu[i].name << "\t" << stu[i].age << endl;
本回答被网友采纳