real clothes shop code help

Hi guys . I want to code a program for a real clothes shop.
They need to enter many product codes then give the sum at end.
The problem is that there are thousands of clothes.
I want to know if I should put all the clothes info in a file and then search the file for the name when the user enter it.
How should I write clothe 's code to thr file and then search for the code in the file? I really need help...
Thanks in advance.
Can you be a little more thorough?
- They need to enter many product codes then give the sum at the end
The sum of what?
The sum of the cost of each piece of clothing?
Does every piece of clothing have a unique code?

Looks like you'll be able to make use of <fstream> and store all your info in a text file.
@walnut . Exactly!
They need to enter a unique products codes then give the sum of the price at end.
I need to use fstream to store my data in a file.
Another problem is how to assign the price for the product code in the file.
Last edited on
I would go about it the following way: Have a text file as a database of your clothing that is easy to read:
Number Name Price (anything else)

13452 RedDressLong 34.95
57736 JeansSize34 29.99
...and so on

Make a class called "Item"
Item (int clothingID, string clothingName, double clothingPrice) //maybe int quantity or bool inStock

Read in data from .txt file as a vector<Item> myStock or something

from then on, just make any function with your myStock.

Person enters clothing number. Match number with the item inside myStock vector. Take down the price, add to any other items, return the sum.
Assuming they are selling the item you can decrement the quantity, and if quantity < 1, inStock = false

Also, add a function to item to alter the price.
item.changePrice(40.25);
And lastly at the end you can ofstream << your info into another text file for an updated database
@walnut How to should I red in data from .txt file as a vector
By reading information into a data structure first like Walnut suggested ( Though I'd prefer a struct over a class ) and pushing the data structure into the vector.
Topic archived. No new replies allowed.