This throws my program into an infinite loop.
Code:ofstream out; string fName; out.close( ); while( !out ) { cout<<"Enter file name: "; cin>>fName; out.open( fName.c_str( ), ios::out | ios::binary ); }
This throws my program into an infinite loop.
Code:ofstream out; string fName; out.close( ); while( !out ) { cout<<"Enter file name: "; cin>>fName; out.open( fName.c_str( ), ios::out | ios::binary ); }
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
You expected something different? What were you expecting it to do?
gg
It's supposed to ask the user for a filename until it is able to open the file for binary output.
Oh, well, that makes sense .
Whenever any of the error bits get set, the are not unset by an open(). You have to do it yourself. Throw an "out.clear()" at the top of your while loop.
gg
Thanks. Works now.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie