المشكلة هي : عندما أقوم بادخال بيانات الc1 و c2 لا تطبع الثانيه ... ما أدري ليييييه
#include
#include
class cars{
private:
char color[10];
char num[10];
int cily;
public:
void get_inf()
{
cout << " hello and welcom ... n ";
cout << "enter the color of car : ";
cin >> color;
cout << "enter the number of the car : ";
cin >> num;
cout << "enter the number of cilenders in the car : ";
cin >> cily;
}
void get_out();
};
void cars::get_out() {
cout << "---------------------------------------------------------------------------"< cout << " the color the number the number of cylenders " << endl;
cout << "---------------------------------------------------------------------------"< cout << "t" << color << "tt" << num << "tt" << cily << endl;
cout << "---------------------------------------------------------------------------"<
}
void main () {
char ch;
fstream a;
cars c1,c2;
a.open("CARS.txt",ios::app|ios::in);
do
{
cout << "the TOYOTA car information : n************************n";
c1.get_inf();
a.write((char *)&c1,sizeof(c1));
cout << "n**enter another TOYOTA car? (y/n):";
cin >> ch;
}while(ch=='y');
//**********************************************************************
do
{
cout << "the NISSAN car information : n************************n";
c2.get_inf();
a.write((char *)&c2,sizeof(c2));
cout << "n**enter another NISSAN car? (y/n):";
cin >> ch;
}while(ch=='y');
//**********************************************************************
//**********************************************************************
a.seekg(0);
a.read((char*)&c1,sizeof(c1));
while(!a.eof())
{
cout << "nnnn The TOYOTA cars informations :- " << endl;
c1.get_out();
a.read((char*)&c1,sizeof(c1));
}
//**********************************************************************
a.seekg(0);
a.read((char*)&c2,sizeof(c2));
while(!a.eof())
{
cout << "nnnn The NISSAN cars informations :- " << endl;
c2.get_out();
a.read((char*)&c2,sizeof(c2));
}
//**********************************************************************
}