الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكلة في fstream.h

مغلق
بدأه essa في 1 أبريل 2003 · 4 رد · 795 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

المشكلة هي : عندما أقوم بادخال بيانات ال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));
	}

	//**********************************************************************

}
#2

السلام عليكم ورحمة الله وبركاته

قد يكون الخطأ في

cin >> color;

//you must use

do

{

++i;

cin.get(color );

{while (color)!= 'n');

color='

#3

مقصود بالفراغ

'   0  '
#4

المشكلة مو في المدخلات ... المشكلة في المخرجات .. يعني يضيف كل نوع من السيارات في جدول لوحده وأنا ما عندي الا نوعين بس من السيارات ... والنتائج تخرج كل سياره في جدول .. هذي هي المشكله :)

هذا الموضوع مغلق.

مواضيع مشابهة