Hello Zero001,
Your code poses more questions than answers.
What IDE are you using and what C++ standard is the compiler using?
Why "cstring" and not "string"?
Why use a file and not an array or vector?
"outFile" uses a cstring for the file name, but "inFile" uses a string for the file name. From C++11 on a std::string will work.
What does the input file look like? You are asking everyone to guess what is in this file.
If yo use something like this in your code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
const std::string DRINKNAMES[]
{
"",
"Coca Cola",
"Pepsi",
"Banana_Shake",
"7up",
"Red_bull",
"Spirte",
"Mango_shake",
"pineapple_juice"
};
constexpr int DRINKPRICES[]
{
0,
60,
70,
80,
70,
90,
60,
80,
200
};
|
After line 19 you need an if statement to compare what is in the file to the choice that is made. For now thinking:
1 2
|
if (line == DRINKNAME[count])
outFile << line <<endl;
|
The problem here is that I am not sure what "line" will contain, so this may have to be adjusted. This way you only output a match and not the whole file.
It is best to stay away from global variables like "string user". This is best defined inside "main" where it is used.
With more information you can get a better response to your question.
Hope this helps,
Andy
Edit: