469,612 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

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

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 '07 #1
13 1123
Ha*******@gmail.com 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.
Mar 1 '07 #2
On Feb 28, 8:42 pm, HardHa...@gmail.com 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 '07 #3
On Feb 28, 8:43 pm, Ian Collins <ian-n...@hotmail.comwrote:
HardHa...@gmail.com 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 '07 #4
Ha*******@gmail.com wrote:
On Feb 28, 8:43 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>HardHa...@gmail.com 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.
Mar 1 '07 #5
Look up the use of the second parameter of open, the mode flag. It
defaults to truncating the file.

--
Ian Collins.
Thanks

Mar 1 '07 #6
Ha*******@gmail.com 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.
Mar 1 '07 #7
On Feb 28, 8:55 pm, Ian Collins <ian-n...@hotmail.comwrote:
HardHa...@gmail.com 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 '07 #8
On Mar 1, 6:42 am, HardHa...@gmail.com 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 '07 #9
Ian Collins wrote:
Ha*******@gmail.com 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
Mar 1 '07 #10
Default User <de***********@yahoo.comwrote:
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
Mar 1 '07 #11
Marcus Kwok wrote:
Default User <de***********@yahoo.comwrote:
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
Mar 1 '07 #12
Default User <de***********@yahoo.comwrote:
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
Mar 1 '07 #13
On Mar 1, 4:45 pm, "Default User" <defaultuse...@yahoo.comwrote:
Marcus Kwok wrote:
Default User <defaultuse...@yahoo.comwrote:
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

Mar 2 '07 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Christo | last post: by
2 posts views Thread by Perrin | last post: by
1 post views Thread by Chris Dunaway | last post: by
8 posts views Thread by HardHackz | last post: by
5 posts views Thread by chaoticcranium | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.