I'm trying to append the end of the file treatments.txt but am unsure how to use the while loop correctly!! Any suggestions?? I tried boolean with the whiles aswell but can't seem to get it to work either. Like asking do you want to continue adding treatments and if yes set bool to false and exit while statement.
void enterTreatments( T * treatArray, int numTreatments)
{
int treatmentNumber = -1;
ofstream outfile;
outfile.open("treatments.txt");
// while(numTreatments > treatmentNumber)
for (int i = 0; i < numTreatments; i++)
{
cout << "Enter treatment ID" << endl;
cin >> treatArray[i].treatmentID;
outfile << treatArray[i].treatmentID;
cin.get();
cout << "Enter treatment Description" << endl;
getline(cin,treatArray[i].treatmentDescription);
outfile << treatArray[i].treatmentDescription;
cout << "Enter cost for treatment" << endl;
cin >> treatArray[i].cost;
outfile << treatArray[i].cost;
cout << "Enter number of required sessions" << endl;
cin >> treatArray[i].noOfRequiredSessions;
outfile << treatArray[i].noOfRequiredSessions;
treatArray[i].costPerSession = treatArray[i].cost/treatArray[i].noOfRequiredSessions;
//cout << "Enter cost per session " << endl;
//cin >> treatArray[i].costPerSession;
cout << "Cost for each session is = " ;
cout << treatArray[i].costPerSession << endl;
cin.get();
outfile << treatArray[i].costPerSession;
treatmentNumber++;
}
}