mấy bác sửa lại giúp em với.
#include<iostream>
#include<fstream>
using namespace std;
class sanpham{
public:
string doday= "";
string loai =" ";
string size = "";
};
void inputInformation(sanpham &SP){
cout<<endl<<" Nhap do day: ";
cin>>SP.doday;
cout<<endl<<" Nhap chung loai: ";
cin>>SP.loai;
cout << endl<<"Nhap vao Size cua SP: ";
cin>>SP.size;
}
int main(){
ofstream file;
sanpham SP[10];
int n=0;
cout<<" Nhap vao so luong san pham: ";
cin >>n;
for( int i=0;i<n;i++){
cout<<endl<<"Nhap du lieu san pham "<<i+1<<":";
inputInformation(SP[i]);
}
file.open("E:\\phanLoaiSanPham.txt",ios::trunc);
for (int i=0;i<n;i++){
file<<endl<<"__________"<<"Thong tin san pham "<<i+1<<":"<<endl<<"Do day: "<<SP.doday<<endl<<"Loai san pham: "<<SP.loai<<endl<<"Kich thuoc :"<<SP.size<<endl;
}
file.close();
cout<<"---------------------------"<<endl<<"Ghi file Thanh Cong.";
return 0;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?