Looks for maybe a few pointers where I could figure out a few things

Getting going in the right direction

Posted 15 June 2009 - 05:20 AM

Ok for starters, great site been looking around and reading alot, extremely helpful.

Now i'm still new to C++, but i've been starting to program a inventory console application in windows, and I just came to the point to where I want to be able to have files holding my information of products.

Like say I can have a menu to let me put in when I get more stock, then when I make a sale it can do all its math and whatnot.

The issue im having is figuring out how I need to write up the code, I got code that will create the file(I just made it "inventory.txt"), But I cannot find a tutorial on making previous stuff stay in files and just add on to what I had before. I know its something simple and right under my nose

I have been searching for like 48 hours and decided to finally ask the community.

Im not asking for code merely just a good shove in the right direction.

Re: Getting going in the right direction

Posted 15 June 2009 - 08:00 AM

CryptiC-, on 15 Jun, 2009 - 04:20 AM, said:

Ok for starters, great site been looking around and reading alot, extremely helpful.

Now i'm still new to C++, but i've been starting to program a inventory console application in windows, and I just came to the point to where I want to be able to have files holding my information of products.

Like say I can have a menu to let me put in when I get more stock, then when I make a sale it can do all its math and whatnot.

The issue im having is figuring out how I need to write up the code, I got code that will create the file(I just made it "inventory.txt"), But I cannot find a tutorial on making previous stuff stay in files and just add on to what I had before. I know its something simple and right under my nose

I have been searching for like 48 hours and decided to finally ask the community.

Im not asking for code merely just a good shove in the right direction.

Thanks in advance,
CryptiC-

you need to set your flags for you file, so say:

ofstream FILE("inventory.txt",ios::app);

ios::app = All output operations are performed at the end of the file, appending the content to the current content of the file.

Re: Getting going in the right direction

Thanks so much for the help so far guys I didnt have much time to mess around with it but I will be when I get off work today.

Again sorry if the post was covered a million times, my search efforts seemed fruitless, just looks like I wasn't looking around very well lol

Any other pages on file i/o or maybe a good reference sheet to print out?

When I come home from work and mess with it ill post my code up on here and let you guys take a look.. Im sure im doing so many wrong things or not very optimized so hopefully I can get more pointers lol