473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 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 1237
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.