Program closes as soon as it opens?
I can't figure it out at all. I'm using Dev C++: for those who don't know, system("PAUSE"); is used to keep the console window open.
For clarification: it's one of those Windows errors that say it has encountered a problem and needs to close.
Code:
#include <cstdlib>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <string.h>
using namespace std;
class Player
{
public:
int punch();
int whut();
void define();
private:
int HP;
int M;
int P;
int D;
int MP;
int MD;
int A;
int damage;
string Class;
string choices[7][7];
};
int Player::punch()
{
float n;
damage = 10;
n = (rand() % 100) + 50;
n = n/100;
damage = (damage * n);
cout << damage << '\n';
}
int Player::whut()
{
int specialty1=0, specialty2=0;
cout << "Pick your first specialty.\n";
cin >> specialty1;
cout << "Pick your second specialty.\n";
cin >> specialty2;
cout << "You chose the " << choices[specialty1][specialty2];
cout << ".\n";
Class = choices[specialty1][specialty2];
}
void Player::define()
{
choices[1][1] = "N/A";
choices[1][2] = "Keeper";
choices[1][3] = "Juggernaut";
choices[1][4] = "Defender";
choices[1][5] = "Battlemage";
choices[1][6] = "Spell Canceler";
choices[1][7] = "Cutpurse";
choices[2][1] = "Keeper";
choices[2][2] = "N/A";
choices[2][3] = "Wizard";
choices[2][4] = "Warlock";
choices[2][5] = "Destroyer";
choices[2][6] = "Spirit Breaker";
choices[2][7] = "Fiend";
choices[3][1] = "Juggernaut";
choices[3][2] = "Wizard";
choices[3][3] = "N/A";
choices[3][4] = "Warrior";
choices[3][5] = "Spellblade";
choices[3][6] = "Knight";
choices[3][7] = "Assassin";
choices[4][1] = "Defender";
choices[4][2] = "Warlock";
choices[4][3] = "Warrior";
choices[4][4] = "N/A";
choices[4][5] = "Spellshield";
choices[4][6] = "Protector";
choices[4][7] = "Rogue";
choices[5][1] = "Battlemage";
choices[5][2] = "Destroyer";
choices[5][3] = "Spellblade";
choices[5][4] = "Spellshield";
choices[5][5] = "N/A";
choices[5][6] = "Mage";
choices[5][7] = "Slayer";
choices[6][1] = "Spell Canceler";
choices[6][2] = "Spirit Breaker";
choices[6][3] = "Knight";
choices[6][4] = "Protector";
choices[6][5] = "Mage";
choices[6][6] = "N/A";
choices[6][7] = "Stalker";
choices[7][1] = "Cutpurse";
choices[7][2] = "Thief";
choices[7][3] = "Assassin";
choices[7][4] = "Rogue";
choices[7][5] = "Slayer";
choices[7][6] = "Stalker";
choices[7][7] = "N/A";
}
int main(int argc, char *argv[])
{
srand(unsigned(time(NULL)));
Player test;
test.define();
test.whut();
system("PAUSE");
return EXIT_SUCCESS;
}