hi Swerve
1:
I'd suggest you to use better names for your variables/structures
(avoid using "my" everywhere since it makes the code less readable).
example:
Code:
struct Item {
char name[MAXCHARS];
double price;
bool luxury;
};
Item itemList[MAXITEMS];
// instead of: mystruct thestructsarrayname[MAXITEMS];
2:
this line is useles: do you need the object instantiated here?
Code:
mystruct mystructname;
3:
Code:
if(!mystream)
{
cout << "phail " << endl;
}
I would use:
if (!mystream.good ())
instead.
Anyway, in case the fstream wouldn't be ok (eg: bad filename) your program should do something, like quit the program, instead of normally continue like you're actually doing.
4:
After the fstream test you do this:
Code:
for(int i = 1;i < 10;i++)
{
cout >> thestructsarrayname[i].price;
}
cout is an ostream (output stream) object of the STL which let you print something to the standard output.
So you are not allowed to use it as an input stream.
At the 3rd line of the main function you create mystream:
Code:
ifstream mystream("myfile2.txt");
why don't use it to fill your struct array?
Code:
mystream >> variable;
Your syntax was ok, but you were trying to use the wrong object.
5:
I'd finally suggest you to first try to read only one type of value:
remove all numbers from the txt file and try to read only the item names.
Then, once you get used with fstream, you can add the doubles and the bool values.