1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
for(int i = 0; i<number_update; i++)
{
cout << endl;
cout << "========="<<endl;
cout << "Record number : " << i + 1 << endl;
cout << "========="<<endl;
cout << "Add a new customer's number" << endl;
cin >> R4F[i].cus_number;
outfile << R4F[i].cus_number << '\t';
cin.ignore();
cout << "Add a new customer's name" << endl;
cin.getline(R4F[i].cus_name, 64);
cout << "Name : " << R4F[i].cus_name << endl;
outfile << (R4F[i].cus_name, 64, '\t');
cout << "Add a new customer's hours used" << endl;
cin >> R4F[i].cus_hour;
outfile << R4F[i].cus_hour << endl;
}
|
Why cant I write name to my txt file ? My txt shows cus_number and cus_hour only.
However, I can cout R4F[i].cus_name in my console instead.
Add a new customer's number
4948435
Add a new customer's name
hue hue
Name : hue hue //cout checking
Add a new customer's hours used
1
|
Last edited on
How have you defined cus_name ?
1 2 3 4 5 6 7 8 9
|
struct record4function
{
int cus_number;
char cus_name[64];
float cus_hour;
float charge;
};
record4function R4F[12];
|
With char.
Last edited on
Why are you using the comma operator here? Do you understand what the operator does in C++?
Thanks Mikey, solved my problem by changing , to <<