do{
cout << "Enter Mobile Number as ( 555 ) to STOP: ";
cin >> MobileNumber;
if(MobileNumber!=-1){
cout<<"Please enter your Firist Name: ";
cin >> FiristName;
cout << "Please enter your Firist Name: ";
cin >> LastName;
cout << "Please enter your Pacage Type";
cin >> Type;
cout << "Please enter how many MG you have been consumed:";
cin >> MB;
customer << MobileNumber << '\t' << FiristName <<'\t' << LastName <<'\t' << Type << "\t"<< MB << endl;
customer.close();}
}
while (MobileNumber!=-1);}
but its write to the file for only once i mean when i enter for example : mobile: 77777777
firist name: jey
last name: adam
type: extra
MB: 55
then loping and enter for another customer it write to the file only the data for jey !?
Yes. The statement customer.close(); is inside the body of the if statement.
That statement should be moved to the last line just before the end of function NewCustomerData(). That is, move it completely outside the do-while loop.
Actually, the file close statement can be omitted completely, as the system will automatically close the file when the fstream is destroyed (at the end of the function).
aha really thanks a lot Mr.chervil it's worrrrrrrk now ^_^
but i have only last problem which with mobile number for example when i enter 777777 its wirte to the file as 7.77778e+006 !!! :(