Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Handling Troubles

Status
Not open for further replies.

WarrenB

Programmer
Feb 7, 2001
38
GB
In the code below the problem is the program is terminating without allowing for input (and thus not saving). Can anybody please help? oh btw, at first the output (please enter location to store) was also not showing automatically until i added the flush instruction. Thanks in advance. (no errors or warnings reported on compile)

void save(struct database outit[3])
{
char filename[20];
int mode = (ios::eek:ut);
int index=0;
cout << &quot;Please enter location to store: &quot;;
cout.flush() // wasn't even displaying this
cin.getline(filename,20);
fstream fout(filename, mode);
for (index=0; index < 4; index++)
{
fout << outit[index].name;
fout << outit[index].age;
}
fout.close();
}
Warren Brown
wazzer@btinternet.com
 
Done that but the program is still unexpectedly terminating as described. Warren Brown
wazzer@btinternet.com
 
I've worked out that it is running through all the code, but for some reason its not stopping for input and it is not writing to the entered location (basically because you can't enter a location, doesn't even work when you pre-specify a location), please help if possible, thanks. Warren Brown
wazzer@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top