when i ran this, it exits after i entered input and press enter, but it's supposed to move to new line for more input.
only when i type end-of-file should it exit.
can anyone help?
Code:#include <iostream> using std::cout; using std::cin; using std::ios; using std::cerr; using std::endl; #include <fstream> using std::ofstream; #include <cstdlib> int main() { // ofstream constructor opens file ofstream outClientFile( "clients.dat", ios::out ); // exit program if unable to create file if ( !outClientFile ) { // overloaded ! operator cerr << "File could not be opened" << endl; exit( 1 ); } cout << "Enter the client number, firstname, surname, street name," << "street number, D.O.B," << '\n' << "and allowance" << endl << "Enter end-of-file to end input.\n? "; int clientNumber; char firstName[ 30 ]; char surName [ 30 ]; char streetName[ 30 ]; int streetNumber; int dateofBirth; double allowance; // read account, name and balance from cin, then place in file while ( cin >> clientNumber >> firstName >> surName >> streetName >> streetNumber >> dateofBirth >> allowance ) { outClientFile << clientNumber << ' ' << firstName << ' ' << surName << ' ' << streetName << ' ' << streetNumber << ' ' << dateofBirth << ' ' << allowance << endl; cout << "? "; } // end while return 0; // ofstream destructor closes file } // end main



LinkBack URL
About LinkBacks


