Hi,
I am trying to write data out to a file on floppy disk,
If the disk is present in the drive the program runs fine and outputs the
data correctly, however if the disk is not present in the drive, the program
enters the while loop which asks user to insert the disk and continuously
tries to open it, after the user has inserted the disk the program seems to
run fine, however there is no data in the output file.I think it could be a
problem with close() (not having a handle to the file) not opperating
properly, some code used:-
outFile.open(out,ios::out);
while(!outFile.is_open())
{
cout<<"Please insert disk into A: drive and press key"<<endl;
getch();
outFile.open(out,ios::out);
} 2 2796
Hi,
"Colum" <co********@hotmail.com> wrote in message
news:PQ****************@news.indigo.ie... Hi, I am trying to write data out to a file on floppy disk, If the disk is present in the drive the program runs fine and outputs the data correctly, however if the disk is not present in the drive, the
program enters the while loop which asks user to insert the disk and continuously tries to open it, after the user has inserted the disk the program seems
to run fine, however there is no data in the output file.I think it could be
a problem with close() (not having a handle to the file) not opperating properly, some code used:-
outFile.open(out,ios::out); while(!outFile.is_open()) { cout<<"Please insert disk into A: drive and press key"<<endl; getch(); outFile.open(out,ios::out); }
Well, if this is the program there shouldn't be any data in the outFile,
where is the part that is writing data in it?
Regards, Ron AF Greve.
Colum wrote in news:PQ****************@news.indigo.ie: Hi, I am trying to write data out to a file on floppy disk, If the disk is present in the drive the program runs fine and outputs the data correctly, however if the disk is not present in the drive, the program enters the while loop which asks user to insert the disk and continuously tries to open it, after the user has inserted the disk the program seems to run fine, however there is no data in the output file.I think it could be a problem with close() (not having a handle to the file) not opperating properly, some code used:-
outFile.open(out,ios::out); while(!outFile.is_open()) { cout<<"Please insert disk into A: drive and press key"<<endl; getch();
You need to clear the error state before you can succesfully retry
the open.
outFile.clear();
outFile.open(out,ios::out); }
HTH.
Rob.
-- http://www.victim-prime.dsl.pipex.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: steve |
last post by:
Is there a way to catch file errors while writing
to a file using ofstream?
For ex., if the file is deleted or permissions changed
by another process after it is opened,
or when the disk is full....
|
by: muser |
last post by:
In the following function there is an access violation error, some
memory can't be read. A week ago this code did compile.
Can anyone possibly tell me why my compiler is unable to read part of...
|
by: muser |
last post by:
In the code I supplied before this one, the cause of the problem is an
access violation error. When I run the debugger it skips into what I
can only assume is the compilers version of my code. And...
|
by: jois.de.vivre |
last post by:
Hi,
I'm trying to write to an ofstream, and for some reason it fails. I
know I can check it with fail() or bad(), but it gives me no useful
information as to why it fails. Are there any C++...
|
by: Squid Seven |
last post by:
I'm trying to use a pointer to an ofstream object and having problems:
ofstream *sessionFile = NULL;
if( directory == "" )
sessionFile = new ofstream( fileName.c_str(), ios::out );
else
{
| |
by: adamrobillard |
last post by:
Hi,
I have always used fopen and FILE* to load and save structures to file.
I am trying to convert all the older code to use proper C++ calls...
the following code works properly but I would...
|
by: coinjo |
last post by:
#include<fstream>
#include<iostream>
#include<cstring>
using namespace std;
struct date
{
int day, month, year;
};
|
by: Trent |
last post by:
Here is the error while using Visual Studio 2005
Error 1 error LNK2019: unresolved external symbol "void __cdecl
print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z) referenced
in...
|
by: aaragon |
last post by:
Hello, does anyone have a clue about this error? and how to solve it?
It seems to be trivial to me, but not for the compiler. I'm using g++
4.2 on an Ubuntu Linux system:
// main()
.......
|
by: Craftkiller |
last post by:
=========Program compiles on both windows and linux===========
Greetings, I am currently working on an encrpytion program that will take a file and a password string and flip the bits based on the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |