I'm new to using deques and other advanced containers like vectors and such. I don't see anything wrong with this but I get the weird "Runtime stopping in a weird way" error at the first for loop.
troopFile.open("Troops Number.txt");
deque<string> names;
string nameInput;
int typeNum;
int nameCounter = 0;
int typeCounter = 0;
int monsterCounter = 0;
int numberCounter = 0;
deque<string> monsters;
string monsterInput;
deque<int> troopNum;
int numberInput;
cout << "Please type the name of who owns the troops: ";
getline(cin,nameInput);
names.push_back(nameInput);
cout << "How many types of troops are to be entered for this user: ";
cin >> typeNum;
cin.ignore();
while(typeCounter < typeNum)
{
cout << "Please type the name of the troop or monster: ";
getline(cin,monsterInput);
monsters.push_back(monsterInput);
cout << "Please type the number of " << monsters.at(monsterCounter) << " that " << names.at(nameCounter) << " owns: ";
cin >> numberInput;
cin.ignore();
typeCounter++;
monsterCounter++;
}
nameCounter = 0;
monsterCounter = 0;
numberCounter = 0;
for (int nameCounter = 0; nameCounter < names.size(); ++nameCounter) //ERROR
{
troopFile << names.at(nameCounter) << endl;
for (int i = 0; i < typeNum; ++i)
troopFile << monsters.at(monsterCounter) << " - " << troopNum.at(numberCounter) << endl;
}
The error I get happens while the console is running. The program reaches the specified for loop and then Windows error thing comes up and says, "Counter has stopped working". In the console window it says, "This application has requested the Runtime to terminate in an unusual way. Please contact the application's support team for more information."