This program keeps going into an infinite loop for some reason. When I delete everything from ofstream builders; to builders.close(); cin.ignore(); it doesn't go into the infinite loop. So the eroor is somewhere in there.
#include
#include
using namespace std;
char builder_name[35];
char choice;
void add_builder()
{
while(choice != 'N' && choice != 'n')
{
// error is somewhere between here
ofstream builders;
builders.open ("builders.txt", ios::app);
cout << " Enter the name of a builder: ";
cin.get(builder_name, 35);
cin.ignore();
builders << builder_name << endl;
builders.close();
cin.ignore();
// and here
cout << " Would you like to add another builder? (enter (Y) or (N): ";
cin >> choice;
}
}
int main ()
{
add_builder();
return 0;
}
2007-03-15
12:01:32
·
4 answers
·
asked by
blueice_1820
2
in
Computers & Internet
➔ Programming & Design