本人大学生,编程遇到一个错误,不会修改,请教大家给看看,谢谢
#include<iostream>#include<fstream>
#include<cstdlib>
using namespace std;
#define N 100
struct Car //定义车辆信息结构体
{
char num[10];
int size;
int rutime;
int ru;
int chutime;
int chu;
float cost;
float km;
char name;
}car[N];
char num[10];
int size;
int rutime;
int ru;
int chutime;
int chu;
float cost;
float km;
char name;
void Input()
{
int i=0;
int M;
cout<<"请输入要录入的数据条数(小于等于100),按回车结束"<<endl;
cin>>M;
fstream file1; //打开文件
file1.open("data",ios::out);
file1<<"num"<<' '<<"size"<<' '<<"rutime"<<' '<<"ru"<<' '<<"chutime" //文件中写入列标
<<' '<<"chu"<<' '<<"cost"<<' '<<"km"<<' '<<"name"<<endl;
cout<<"请按顺序输入num,size,rutime,ru,chutime,chu,cost,km,name"<<endl;
for(i;i<N;i++) //循环向文件中输入具体数据
{
cin>>num>>size>>rutime>>ru>>chutime>>chu>>cost>>km>>name;
car[i].num=num;
car[i].size=size;
car[i].rutime=rutime;
car[i].ru=ru;
car[i].chutime=chutime;
car[i].chu=chu;
car[i].cost=cost;
car[i].km=km;
car[i].name=name;
file1<<car[i].num<<' '<<car[i].size<<' '<<car[i].rutime<<' '<<car[i].ru<<' '<<car[i].chutime
<<' '<<car[i].chu<<' '<<car[i].cost<<' '<<car[i].km<<' '<<car[i].name<<endl;
}
}
注释
不好意思,第一次发帖,新人一个,可能格式什么不对~~不好意思