First of all, I'm new to Daniweb and I would like to thank in advance to all those who take their precious time to help me. I appreciate it greatly. Hopefully, I'll get good enough to contribute and help others in the Daniweb developing community, as well.
The problem I'm having has to do with, as suggested in the thread title, variable for loops. I'm making a function the prints out an std::map, 10 containers at a time using a for loop inside a while loop. Heres the code:
...
LoadMap();
map<string, int>const_iterator pos;
int in1(1),in2(11);
bool ib1;
do {
for (i = in1; i <in2; ++i)
{
if (map::container != empty)
cout<< (*pos)->second << (*pos)->first<<endl;
++pos;
}
getline(cin, line);
if (statement1 == true)) {
in2+=10;
in3+=10;}
if (statement2 == true) {
ib1 = false;}
} while (ib1 = true);
...
To be clear, LoadMap() loads the map from a .txt file succesfully and I might have missed declaring some variables in the code above, but they're all declared in the program. Statement1 more or less asks if the user wants to continue to the next page, and statement2 if he wants to exit.
Now here's the thing: the program works. It prints out the contents of the std::map. The problem is that it crashes without letting me input anything. Now I've played a little bit with the code, and made everything work perfectly fine by replacing the variables in1 and in2 with set numbers like 1 and 11, respectively. So, again, to be clear, having variable parameters in the for loop is whats crashing my program. I don't know why its doing that, and I could really use some help. Again, truckloads of appreciation and gratitude for helping me on this.