File cannot open with ofstream constructor !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tornado

    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.
  • Mike Wahler

    #2
    Re: File cannot open with ofstream constructor !


    tornado <tornado579@yah oo.com> wrote in message
    news:c8b0a275.0 307290306.2d357 ad0@posting.goo gle.com...[color=blue]
    > 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 ![/color]

    Show us your code.
    [color=blue]
    >The
    > c++ book by Herbert Schildt[/color]

    See http://snurse-l.org/acllc-c++/faq.html#q6.4
    [color=blue]
    >which i m readin mentions that ofstream
    > default constructor can open a file.[/color]

    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?
    [color=blue]
    > But when i tried to open a file
    > it failed to open.[/color]

    Show us the code you used, and tell us what indicates
    to you the open failed.
    [color=blue]
    >Then i tried it by open method which succeded.
    > I m using g++ on Redhat linux.
    >
    > Any insights will be appreciated.[/color]

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

    -Mike



    Comment

    Working...