By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
13 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.