When i compile this i don't get any error messages but when i run the prog and it gets to the attack or flee option it prints out a bunch of lines and quits!!!! I think it said something about "Call frame traceback"...
And i know that the code isn't too good and that some stuff isn't being used yet.
Code:#include <iostream.h> #include <stdlib.h> #include <conio.h> #include <stdio.h> #include <dos.h> #include <fstream.h> ifstream infile; ofstream outfile; struct CHARACTER { char name[50]; char weapon[20]; int hp; int lvl; int damage; int damBonus; int exp; int nextlvlexp; int skill; }; struct MONSTER { char* name; int hp; int damage; int skill; int defeatexp; }; CHARACTER chr; MONSTER m; int battleChoice; int tempDam; int monsternr; int tempskill; int getMonster() { monsternr = rand() % 3; switch(chr.lvl) { case 1: switch(monsternr) { case 0: m.name = "Rat"; m.hp = 4; m.damage = 2; m.defeatexp = 25; case 1: m.name = "Goblin"; m.hp = 6; m.damage = 3; m.defeatexp = 40; case 2: m.name = "Giant Worm"; m.defeatexp = 45; m.hp = 7; m.damage = 2; return 0; } } } void writeHP(int hp) { for (int i = 0;i<hp;i++) { cout << "#"; } } void p() { while(!kbhit()); getch(); } int paintFight() { clrscr(); cout << "\n\nYour HP: "; writeHP(chr.hp); cout << "\n\n"; cout << "Enemy's HP: "; writeHP(m.hp); cout << "\n\n"; } void createChar() { cin >> chr.name; chr.hp = 13; chr.lvl = 1; chr.damage = rand() % 2 +1; } void charAttack() { tempskill = rand() % chr.skill; if(tempskill > m.skill/2) { tempDam = rand() % chr.damage; m.hp = m.hp - tempDam + chr.damBonus; cout << "\n\nYou hit the enemy!\n\n"; delay(2000); cout << "The hit does " << tempDam + chr.damBonus << "\n\n"; delay(2000); } else { cout << "\n\nYou miss!\n\n"; delay(2000); } } int mtempskill; void mAttack() { mtempskill = rand() % m.skill; if(tempskill > chr.skill/2) { chr.hp = chr.hp - m.damage; } } int main() { createChar(); getMonster(); cout << "You stumble upon a " << m.name; delay(2000); while(m.hp>0) { paintFight(); cout << "1. Attack\n"; cout << "2. Flee\n\n"; cin >> battleChoice; switch(battleChoice) { case 1: charAttack(); mAttack(); continue; case 2: cout << "You flee"; break; } } cout << "\n\nWhat do you want to do now?\n\n"; cout << "1. Find another monster"; cout << "2. Save"; cout << "3. Quit"; return 0; }