Good night every one ... when i run my program 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 !?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
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);}
FIRST: When you post code here, please use code tags under the format options. Thx
You misspelled First.
also I'm not sure but Pacage, may be spelled Package.
That is not the problem of course. Just wanted to point that out.
Your program tells users to type in the number as (123)456-7890 which is ok, but "()-" are not numbers. Therefor you can not use MobileNumber as a double, int, float or any other numeric value. you can use it as a string, or maybe char. And that seems to be the problem.