File cannot open with ofstream constructor !

Discussion in 'C++' started by tornado, Jul 29, 2003.

  1. tornado

    tornado Guest

    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.
    tornado, Jul 29, 2003
    #1
    1. Advertising

  2. tornado

    Mike Wahler Guest

    tornado <> wrote in message
    news:...
    > 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
    Mike Wahler, Jul 29, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ml
    Replies:
    0
    Views:
    1,444
  2. ml
    Replies:
    2
    Views:
    4,844
    John C. Bollinger
    Nov 30, 2004
  3. sam

    ofstream open bit

    sam, May 6, 2005, in forum: C++
    Replies:
    5
    Views:
    3,168
  4. Squid Seven

    ofstream * vs. ofstream

    Squid Seven, Jul 13, 2005, in forum: C++
    Replies:
    5
    Views:
    595
    Ivan Johansen
    Jul 14, 2005
  5. Generic Usenet Account
    Replies:
    10
    Views:
    2,217
Loading...

Share This Page