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

H

HardHackz

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?
 
I

Ian Collins

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?
 
H

HardHackz

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?
 
H

HardHackz

Learn how to use your editor?

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;
}
 
I

Ian Collins

*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.
 
C

chevrossie13

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...
 
D

Default User

Ian said:
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
 
D

Default User

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

Google Groups isn't a real newsreader ;)

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



Brian
 
M

Marcus Kwok

Default User said:
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 :)
 
D

Diego Martins

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top