Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > The n00b is back...help with outpout to file...

Reply
Thread Tools

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

 
 
HardHackz@gmail.com
Guest
Posts: n/a
 
      03-01-2007
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?

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      03-01-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
 
 
 
HardHackz@gmail.com
Guest
Posts: n/a
 
      03-01-2007
On Feb 28, 8:42 pm, (E-Mail Removed) 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?

 
Reply With Quote
 
HardHackz@gmail.com
Guest
Posts: n/a
 
      03-01-2007
On Feb 28, 8:43 pm, Ian Collins <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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;
}

 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      03-01-2007
(E-Mail Removed) wrote:
> On Feb 28, 8:43 pm, Ian Collins <(E-Mail Removed)> wrote:
>
>>(E-Mail Removed) 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.
 
Reply With Quote
 
HardHackz@gmail.com
Guest
Posts: n/a
 
      03-01-2007
> Look up the use of the second parameter of open, the mode flag. It
> defaults to truncating the file.
>
> --
> Ian Collins.


Thanks

 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      03-01-2007
(E-Mail Removed) 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.
 
Reply With Quote
 
HardHackz@gmail.com
Guest
Posts: n/a
 
      03-01-2007
On Feb 28, 8:55 pm, Ian Collins <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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

 
Reply With Quote
 
chevrossie13@gmail.com
Guest
Posts: n/a
 
      03-01-2007
On Mar 1, 6:42 am, (E-Mail Removed) 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...

 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      03-01-2007
Ian Collins wrote:

> (E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
n00b Help Setting up MSDE SQL Server newgenre ASP .Net 4 04-27-2004 04:13 PM
n00b needs SQL Server newgenre ASP .Net 2 04-15-2004 05:28 PM
n00b Help with Beginning SQL for ASP.NET App newgenre ASP .Net 1 04-14-2004 06:03 PM
N00b 413Rt - need help Joseph Good Cisco 2 04-04-2004 05:11 PM
ultimate n00b question re: my / our Koncept Perl 3 12-06-2003 10:58 PM



Advertisments