473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

File cannot open with ofstream constructor !

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 mentions that ofstream
default constructor can open a file. But when i tried to open a file
it failed to open. Then i tried it by open method which succeded.
I m using g++ on Redhat linux.

Any insights will be appreciated.
Thanks in advance.
Jul 19 '05 #1
1 3399

tornado <to********@yahoo.com> wrote in message
news:c8**************************@posting.google.c om...
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 !
Show us your code.
The
c++ book by Herbert Schildt
See http://snurse-l.org/acllc-c++/faq.html#q6.4
which i m readin mentions that ofstream
default constructor can open a file.
Did you misread that part, or is this another 'Schildtism'?
Class 'ofstream' does provide a default constructor, but
it certainly does not open a file? Which file would it open?
But when i tried to open a file
it failed to open.
Show us the code you used, and tell us what indicates
to you the open failed.
Then i tried it by open method which succeded.
I m using g++ on Redhat linux.

Any insights will be appreciated.


Show us a small, compilable example program which
exhibits the problem behavior, and perhaps we can
help.

-Mike

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: muser | last post by:
Karl this is albeit your program, in the program that you wrote for me I learned quite alot, i didn't realise I could return NULL for instance or even use functions without first declaring them,...
6
by: Omid | last post by:
Hi. I have problems when I try to redirect everything that is sent to cout to a file. I have one piece of code that works and one that does not work. The only difference is which headers I use....
6
by: pembed2003 | last post by:
Hi all, Given something like: std::ofstream out_file("path"); how do I extract the file descriptor from out_file? Is it possible? What I want is to extract the file descriptor and then pass...
2
by: Eat_My_Shortz | last post by:
I'm trying to interoperate between file IO operations, on an open file, between unmanaged C++ code and Managed C++, using the .NET framework. Basically, at present, I have a C-style FILE* object,...
4
by: Anton Pervukhin | last post by:
Hi everybody! I have a small problem regarding the initialization of pointer to the file stream under some conditions. Imagine a class which has a pointer to output file stream and some...
1
by: Avner | last post by:
I have a C++ code which I want to upgrade to the standard C++ The code constructs a file and sets the file permission The new iostream library does not include filebuf::openprot The old...
15
by: Gan Quan | last post by:
I'm writing a c++ program that has many (100+) threads read/write files simultaneously. It works well if not considering the efficiency. The file i/o seems to be the bottleneck. This is my code...
5
by: B. Williams | last post by:
I need some assistance with random access file processing. I have a function that I would like to change from sequential file processing to random access. Thanks in advance. void...
2
by: reyalp | last post by:
I use C++ Builder to create a simple project that can open a picture and save some text information to a file My question is that: After I execute the open picture dialog(btn_OpenPicture) and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.