The n00b is back...help with outpout to file...

Discussion in 'C++' started by HardHackz@gmail.com, Mar 1, 2007.

  1. Guest

    Hey, I'm having a little problem editing a file. Whenever I put
    something into it, it erases the old thing, is there a way to fix this
    so it doesn't erase the last thing?
    , Mar 1, 2007
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > Hey, I'm having a little problem editing a file. Whenever I put
    > something into it, it erases the old thing, is there a way to fix this
    > so it doesn't erase the last thing?
    >

    Learn how to use your editor?

    --
    Ian Collins.
    Ian Collins, Mar 1, 2007
    #2
    1. Advertising

  3. Guest

    On Feb 28, 8:42 pm, wrote:
    > Hey, I'm having a little problem editing a file. Whenever I put
    > something into it, it erases the old thing, is there a way to fix this
    > so it doesn't erase the last thing?


    Sorry for double post, but does anyone have any good C++ tutorials
    besides the one at cplusplus.com?
    , Mar 1, 2007
    #3
  4. Guest

    On Feb 28, 8:43 pm, Ian Collins <> wrote:
    > wrote:
    > > Hey, I'm having a little problem editing a file. Whenever I put
    > > something into it, it erases the old thing, is there a way to fix this
    > > so it doesn't erase the last thing?

    >
    > Learn how to use your editor?
    >
    > --
    > Ian Collins.


    o.0

    No, like this:

    // basic file operations
    #include <iostream>
    #include <fstream>
    using namespace std;

    int main () {
    ofstream myfile;
    myfile.open ("example.txt");
    myfile << "Writing this to a file.\n";
    myfile.close();
    return 0;
    }
    , Mar 1, 2007
    #4
  5. Ian Collins Guest

    wrote:
    > On Feb 28, 8:43 pm, Ian Collins <> wrote:
    >
    >> wrote:
    >>
    >>>Hey, I'm having a little problem editing a file. Whenever I put
    >>>something into it, it erases the old thing, is there a way to fix this
    >>>so it doesn't erase the last thing?

    >>
    >>Learn how to use your editor?
    >>


    *Please trim signatures*
    >
    > o.0
    >
    > No, like this:
    >
    > // basic file operations
    > #include <iostream>
    > #include <fstream>
    > using namespace std;
    >
    > int main () {
    > ofstream myfile;
    > myfile.open ("example.txt");


    Look up the use of the second parameter of open, the mode flag. It
    defaults to truncating the file.

    --
    Ian Collins.
    Ian Collins, Mar 1, 2007
    #5
  6. Guest

    > Look up the use of the second parameter of open, the mode flag. It
    > defaults to truncating the file.
    >
    > --
    > Ian Collins.


    Thanks
    , Mar 1, 2007
    #6
  7. Ian Collins Guest

    wrote:
    >>Look up the use of the second parameter of open, the mode flag. It
    >>defaults to truncating the file.
    >>

    >
    > Thanks
    >

    Next time, *Please trim the signature* that's the bit after the "-- ".
    If you use a news reader, it should do this by default.

    --
    Ian Collins.
    Ian Collins, Mar 1, 2007
    #7
  8. Guest

    On Feb 28, 8:55 pm, Ian Collins <> wrote:
    > wrote:
    > >>Look up the use of the second parameter of open, the mode flag. It
    > >>defaults to truncating the file.

    >
    > > Thanks

    >
    > Next time, *Please trim the signature* that's the bit after the "-- ".
    > If you use a news reader, it should do this by default.


    Okay, sorry
    , Mar 1, 2007
    #8
  9. Guest

    On Mar 1, 6:42 am, wrote:
    > Hey, I'm having a little problem editing a file. Whenever I put
    > something into it, it erases the old thing, is there a way to fix this
    > so it doesn't erase the last thing?


    hey you might have given this thing:
    fopen("somefile name","w");
    instead of w write "a" which means appending
    in this way you wont lose the previous data...
    , Mar 1, 2007
    #9
  10. Default User Guest

    Ian Collins wrote:

    > wrote:
    > > > Look up the use of the second parameter of open, the mode flag.
    > > > It defaults to truncating the file.
    > > >

    > >
    > > Thanks
    > >

    > Next time, *Please trim the signature* that's the bit after the "-- ".
    > If you use a news reader, it should do this by default.



    He's using Google Groups, and that's not one of their features.




    Brian
    Default User, Mar 1, 2007
    #10
  11. Marcus Kwok Guest

    Default User <> wrote:
    > Ian Collins wrote:
    >> Next time, *Please trim the signature* that's the bit after the "-- ".
    >> If you use a news reader, it should do this by default.

    >
    > He's using Google Groups, and that's not one of their features.


    Google Groups isn't a real newsreader ;)

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply
    Marcus Kwok, Mar 1, 2007
    #11
  12. Default User Guest

    Marcus Kwok wrote:

    > Default User <> wrote:
    > > Ian Collins wrote:
    > >> Next time, *Please trim the signature* that's the bit after the

    > "-- ". >> If you use a news reader, it should do this by default.
    > >
    > > He's using Google Groups, and that's not one of their features.

    >
    > Google Groups isn't a real newsreader ;)


    People got bent out of shape last time I said that, so I refrained from
    commentary.



    Brian
    Default User, Mar 1, 2007
    #12
  13. Marcus Kwok Guest

    Default User <> wrote:
    > Marcus Kwok wrote:
    >> Google Groups isn't a real newsreader ;)

    >
    > People got bent out of shape last time I said that, so I refrained from
    > commentary.


    Well, I added a winking smiley, so that should make it clearer that I
    was kidding... but not really :)

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply
    Marcus Kwok, Mar 1, 2007
    #13
  14. On Mar 1, 4:45 pm, "Default User" <> wrote:
    > Marcus Kwok wrote:
    > > Default User <> wrote:
    > > > Ian Collins wrote:
    > > >> Next time, *Please trim the signature* that's the bit after the

    > > "-- ". >> If you use a news reader, it should do this by default.

    >
    > > > He's using Google Groups, and that's not one of their features.

    >
    > > Google Groups isn't a real newsreader ;)

    >
    > People got bent out of shape last time I said that, so I refrained from
    > commentary.
    >
    > Brian


    this is pertinent. I only could get back to usenet because of
    googlegroups. I am sure there is a similar case for many good people
    from here

    many news servers disappeared or become paid :(

    google sucks, but works (mostly)

    Diego
    Diego Martins, Mar 2, 2007
    #14
    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. newgenre
    Replies:
    1
    Views:
    310
    Curt_C [MVP]
    Apr 14, 2004
  2. newgenre

    n00b Help Setting up MSDE SQL Server

    newgenre, Apr 18, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,335
  3. John McClamrock

    ASP.NET n00b needs help here

    John McClamrock, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    338
  4. Christo

    n00b help

    Christo, Oct 27, 2004, in forum: C++
    Replies:
    12
    Views:
    792
    Howard
    Oct 27, 2004
  5. Anton Gavrilov

    Please help a n00b write a compiler :-)

    Anton Gavrilov, Dec 18, 2003, in forum: C Programming
    Replies:
    15
    Views:
    595
    Malcolm
    Dec 19, 2003
Loading...

Share This Page