C++ifstream 文件写入的问题
voidCadmin_info::output(){std::ofstreamfile;file.open("班次信息.txt",ios_base::app);file<...
void Cadmin_info::output(){
std::ofstream file;
file.open("班次信息.txt",ios_base::app);
file<<number<<" "<<_origin<<" "<<_destination<<" "<<h_star<<" "<<m_star<<" "<<h_arrive<<" "<<m_arrive<<" "<< numofstand<<" "<<priceofstand<<" "<<numofhardseat<<" "<<priceofhardseat<<" "<<numofhardsleeper<<" "<< priceofhardsleeper<<" "<<numofsoftsleeper<<" "<<priceofsoftsleeper<<endl;
file.close();
}
void Cadmin_info::input(){
ifstream file;
file.open("班次信息.txt");
char a[100];
file.getline(a,' ');
}
我的目的是:向从TXT中把number _origin _destination 等这些变量一个一个取出来,然后赋值给别的变量。如a=number; 如何实现? 是否应该用getline,或者别的方法呢? 展开
std::ofstream file;
file.open("班次信息.txt",ios_base::app);
file<<number<<" "<<_origin<<" "<<_destination<<" "<<h_star<<" "<<m_star<<" "<<h_arrive<<" "<<m_arrive<<" "<< numofstand<<" "<<priceofstand<<" "<<numofhardseat<<" "<<priceofhardseat<<" "<<numofhardsleeper<<" "<< priceofhardsleeper<<" "<<numofsoftsleeper<<" "<<priceofsoftsleeper<<endl;
file.close();
}
void Cadmin_info::input(){
ifstream file;
file.open("班次信息.txt");
char a[100];
file.getline(a,' ');
}
我的目的是:向从TXT中把number _origin _destination 等这些变量一个一个取出来,然后赋值给别的变量。如a=number; 如何实现? 是否应该用getline,或者别的方法呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询