472,954 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

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 1226
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
I'd like to overwrite just one line of a binary file, based on a position set by seek(). Is there no way to do this? As far as I can tell I need to read the whole file, change the line, and write...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
2
by: Perrin | last post by:
Hi, I am new to these forums so I don't know if this is the appropriate place to post it, but Iam really stuck and I need help :( I have this assignment with structs in C++. basically the...
1
by: Chris Dunaway | last post by:
I am using the following code to test an .aspx page which has no presentation and only a handler for the Page_Load event. I am using this code to POST the contents of an .xml file to the .aspx...
8
by: HardHackz | last post by:
Hey, I'm trying to learn C++, the problem is, when I do cout << "Hello World!"; it always opens dos and closes it to quickly to see...i know im a total n00b, but any help?
5
by: chaoticcranium | last post by:
Right now, I am reading a file line by line using getline() using this code: // Read file line by line, store the first 3 values on each line in a vector and store the vector in a vector of...
2
by: SM | last post by:
Hello i have a constant define like this define('PHOTOGRAPHY', 'images/photography/'); The outpout (html) should look like this: <img src"images/photography/123.jpg"> How do i insert a...
0
by: hockeyjk | last post by:
All, I'm writing a program that creates a histogram of data. IDLE is freezing up after the window opens (doesn't prompt user or graph anything). The window that opens is named "tk" rather than...
4
by: ig | last post by:
First off, I'm a python n00b, so feel free to comment on anything if I'm doing it "the wrong way." I'm building a discrete event simulation tool. I wanted to use coroutines. However, I want to know...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.