Hi,
If I write the following code:
ofstream f;
f.open("c:\\hello.txt", ios::binary | ios::out);
how do I check if the file is successfully opened and ready to write ?
Should I do a f.is_open() check ?
Regards,
...ab 3 1990
how do I check if the file is successfully opened and ready to write ?
Try:
if ( f.good() )
{
// Write...
}
"Abubakar" <s@s.comwrote in message
news:O6**************@TK2MSFTNGP05.phx.gbl...
Hi,
If I write the following code:
ofstream f;
f.open("c:\\hello.txt", ios::binary | ios::out);
how do I check if the file is successfully opened and ready to write ?
Should I do a f.is_open() check ?
Regards,
..ab
Thanks, n what if write() function fails.
...ab
"Michael Phillips, Jr." <mp*********@nospam.jun0.c0mwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>how do I check if the file is successfully opened and ready to write ?
Try:
if ( f.good() )
{
// Write...
}
"Abubakar" <s@s.comwrote in message
news:O6**************@TK2MSFTNGP05.phx.gbl...
>Hi,
If I write the following code:
ofstream f; f.open("c:\\hello.txt", ios::binary | ios::out);
how do I check if the file is successfully opened and ready to write ? Should I do a f.is_open() check ?
Regards,
..ab
Thanks, n what if write() function fails.
Then f.fail() will return true.
"Abubakar" <s@s.comwrote in message
news:ex**************@TK2MSFTNGP03.phx.gbl...
Thanks, n what if write() function fails.
..ab
"Michael Phillips, Jr." <mp*********@nospam.jun0.c0mwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>how do I check if the file is successfully opened and ready to write ?
Try: if ( f.good() ) { // Write... }
"Abubakar" <s@s.comwrote in message news:O6**************@TK2MSFTNGP05.phx.gbl...
>>Hi,
If I write the following code:
ofstream f; f.open("c:\\hello.txt", ios::binary | ios::out);
how do I check if the file is successfully opened and ready to write ? Should I do a f.is_open() check ?
Regards,
..ab
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: tornado |
last post by:
hi all,
This is quite puzzling me why is that ofstream constructor is unable
to open a file for writing while, a ofstream "open" method can ! The
c++ book by Herbert Schildt which i m readin...
|
by: red floyd |
last post by:
Is there any way to retrieve the filename given to a std::ofstream
(passed in constructor or in ofstream::open())?
Or, should I derive from ofstream (should probably be a template to
handle...
|
by: Tom Johnson |
last post by:
Hi all, I cant believe that Im stuck on such simple code, but I am
so...
Im trying to open a text file for writing but can never get the file
to initially open. Heres what Im having trouble with....
|
by: phoenix |
last post by:
How can i read a numbers from file.. I created this file like this:
int dane, i;
std::ofstream plik_z;
plik_z.open(nazwa, std::ios::out | std::ios::trunc | std::ios::binary);
for (i = 0; i <...
|
by: wobudui |
last post by:
Hi everyboday, I have some trouble in dealing with the file stream.
My souce code Listed hear:
int main()
{
char buffer={0};
ofstream ofile.open("mydata.in",ios::app);
ofile.seekp(10);...
|
by: Kush |
last post by:
Hello All,
I am having problem writing some data to file and I do not understand
my mistake / misconception.
I am trying to write some simple text to file but the text is rather
output to...
|
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: jerry |
last post by:
i have written a simple phonebook program,i'll show you some of the
codes,the program's head file is member.h . i suppose the head file
works well.so i don't post it. here's the clips of main...
|
by: Ramesh |
last post by:
Hello,
I am using the ofstream class to create a text file with keys and
values like:
Key1=Value10
Key2=Value15
Key3=Value20
In case I need to set a new value for Key2, say value50 - I am...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |