C++文件数据读取问题
来源:百度知道 编辑:UC知道 时间:2024/08/22 01:36:19
#include<iostream.h>
#include<fstream.h>
struct Date
{
int year;
int month;
int day;
};
struct Student
{
char no[9];
char name[9];
char sex[3];
int score[4];
struct Date birthday;
};
int count;
struct Student stu[30];
void Input()
{
fstream f;
f.open("D:/Dat/StuInfo.dat",ios::out,0);
cout<<"请输入班里的人数:\n";
cin>>count;
for(int i=0;i<count;i++)
{
cout<<"请输入第"<<i+1<<"位同学的学号:\n";
cin>>stu[i].no;
cout<<"请输入第"<<i+1<<"位同学的姓名:\n";
cin>>stu[i].name;
cout<<"请输入第"<<i+1<<"位同学的性别:\n";
cin>>stu[i].sex;
for(int j=0;j<3;j++)
{
cout<<"请输入第"<<i+1<<"位同学的"<<"第&
#include<fstream.h>
struct Date
{
int year;
int month;
int day;
};
struct Student
{
char no[9];
char name[9];
char sex[3];
int score[4];
struct Date birthday;
};
int count;
struct Student stu[30];
void Input()
{
fstream f;
f.open("D:/Dat/StuInfo.dat",ios::out,0);
cout<<"请输入班里的人数:\n";
cin>>count;
for(int i=0;i<count;i++)
{
cout<<"请输入第"<<i+1<<"位同学的学号:\n";
cin>>stu[i].no;
cout<<"请输入第"<<i+1<<"位同学的姓名:\n";
cin>>stu[i].name;
cout<<"请输入第"<<i+1<<"位同学的性别:\n";
cin>>stu[i].sex;
for(int j=0;j<3;j++)
{
cout<<"请输入第"<<i+1<<"位同学的"<<"第&
//结构定义,写入与显示的函数不变
#include<iostream.h>
#include<fstream.h>
struct Date
{
int year;
int month;
int day;
};
struct Student
{
char no[9];
char name[9];
char sex[3];
int score[4];
struct Date birthday;
};
int count;
struct Student stu[30];
void Input()
{
fstream f;
f.open("D:/StuInfo.dat",ios::out,0);
cout<<"请输入班里的人数:\n";
cin>>count;
for(int i=0;i<count;i++)
{
cout<<"请输入第"<<i+1<<"位同学的学号:\n";
cin>>stu[i].no;
cout<<"请输入第"<<i+1<<"位同学的姓名:\n";
cin>>stu[i].name;
cout<<"请输入第"<<i+1<<"位同学的性别:\n";
cin>>stu[i].sex;
for(int j=0;j<3;j++)
{
cout<<"请输入第"<<i+1<<"位同学的&quo