Having read over some of the disscussions involving incrementing variable names in C++, I have the impression that it's impossible. Is that true? I have a very definite need for them in the following program, and an array won't work. I need to read over a file and store certain information in a struct (person dave; dave.money=200 etc.). However, to stay true to the spec I shouldn't assume that there will always be x many entries I need to store. This means I should have a dynamic amount of struct declarations, and this seems impossible to me.
Is there any way to do this?
The struct:
- struct person{
-
string name;
-
vector<string> repnames;
-
int money;
-
int togive;
-
};
What I need to do:
- void readloop(int othernumber, fstream &niceinfile, vector<string>namespace2, int count){
-
person dave;
-
input>>dave.name;
-
input>>dave.money;
-
input>>dave.togive;
-
}
...Except change dave to S1-x, or anything else that will work. Can I use c_str() to do this, maybe? I'm at a loss for what to do here.