Runtime Error with my .exe

Hello guys I've only been learning C++ for a couple of days and have been following this website's guides: https://sites.google.com/site/thepenguinprogrammer/

I have been following the RPG guide (using Dev-C++) and after a while of following it i decided to quickly check if it was working right, but for some reason it wasnt. Whenever i run it i get an error that says "The application has requested the runtime to terminate it in an unusual way."

I debugged it with MVS12 and it came up with the following:
1
2
3
4
5
6
7
'The Hero of Golar Part 1.exe' (Win32): Loaded 'C:\Dev-Cpp\The Hero of Golar Part 1.exe'. Module was built without symbols.
'The Hero of Golar Part 1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'The Hero of Golar Part 1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'The Hero of Golar Part 1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'The Hero of Golar Part 1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
The thread 0x1840 has exited with code 0 (0x0).
The program '[6220] The Hero of Golar Part 1.exe' has exited with code 3 (0x3).


Here's the games code as well, in case I messed it all up.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include <iostream>
#include <string>
using namespace std;

bool running = 1;
void titleFunc();
int userInput = 0;
int playerInfo[2];
int playerLocation = 0;
const int MAX_ITEMS = 100;
int playerItems[MAX_ITEMS][10];
string itemNames[] = { "Sword", "Average Clothing", "Rusted Armor" };
string playerName = 0;
bool itemPickedUp2 = 0;
bool itemPickedUp4 = 0;
short playerItemCount = 0;
int main() {
cout << "\t\t\t\t---Hero of Golar: Part 1---\n\n\n";
cout << "\t\t\t\t   1: Play\n";   
cin >> userInput;    
if(userInput == 1){
void newGameFunc(); {
void menuFunc();{
return 0;
}
void menuFuncNav(); {
return 0;
}
void menuFuncInfo(); {
cout << playerName << "\n";                         
cout << "Gender: \n";
if(playerInfo[0] == 1) cout << "Male\n";
else if(playerInfo[0] == 2) cout << "Female\n";
cout << "Class: \n";
if(playerInfo[1] == 1) cout << "Warrior\n";
if(playerInfo[1] == 2) cout << "Rogue\n";
if(playerInfo[1] == 3) cout << "Mage\n";
return 0;
}
void menuFuncItems(); {
for(int i = 0; i < playerItemCount; i++){
cout << i+1 << ": ";
cout << itemNames[playerItems[i][0]];
cout << "\n";
cin >> userInput;                                   
cout << "\nName: " << itemNames[playerItems[userInput][0]] << "\n";                                  
if(playerItems[userInput][1] == 1)
cout << "Weapon: " <<playerItems[userInput][2] << "\n";
cout << "Armor: " <<playerItems[userInput][2] << "\n";
cout << "Consumable: " <<playerItems[userInput][2] << "\n";
cout << "Quest: " <<playerItems[userInput][2] << "\n";
cout << "Misc: " <<playerItems[userInput][2] << "\n";
cout << "Press ENTER to continue ";
cin >> userInput;
}
return 0;
}
cout << "In the land of Golar, the 3 races: Orcs, Elves, and Humans.\n";
cout << "The Humans dominate the southern half of Golar and are primely chaoitc.\n";
cout << "The Elves remain balanced and try not to meddle in the other races affairs.\n";
cout << "The Orcs remain lawful to their ancestral roots and are rvials of the Humans.\n";
cout << "The war between the Orcs and Humans have climaxed with the death of prince Frodan.\n";
cout << "The Elves have sought for you to end the conflict for good and bring peace to Golar,\n";
cout << "What's your name?\n";
cin>> userInput;         
playerName = userInput;
cout << "So, are you a boy or a girl?\n 1: Boy\n 2: Girl\n";
cin >> userInput;
playerInfo[0] = userInput;        
cout << "And what kind of person are you?\n 1: Warrior\n 2: Rogue\n 3: Mage\n";
cin >> userInput;
playerInfo[1] = userInput;
playerLocation = 1;
while(running){
if(playerLocation == 1) {
cout << "You are at the city of Gurdenport, the captial of the Elven Kingdom.\n";
cout << "It's located on the northern tip of an island between 2 fjords.\n";
cout << "Your superiors have ordered you to help end the war between the Orcs and Humans.\n";
cout << "You have been told you have to go to Gateville for further information.\n";
cout << "1: Go to the Gurden Tundra (South)\n 2: Take a boat to Novgorod (West).\n";
cin >> userInput;
if(userInput == 1) playerLocation = 2;
else if(userInput == 2) playerLocation = 3; 
playerItems[playerItemCount][0] = 0;
playerItems[playerItemCount][1] = 1;
playerItems[playerItemCount][2] = 5;
playerItemCount++;
playerItems[playerItemCount][0] = 2;
playerItems[playerItemCount][1] = 2;
playerItems[playerItemCount][3] = 1;
playerItemCount++;                               
}
if(playerLocation == 3) {
cout << "You arrive to Novgorod safely and quickly.\n";
cout << "Novgorod is a large fishing town with an inn, and dusk is falling.\n";
cout << " 1: Rest in the inn.\n 2: Go south into the snow forests.\n";
cin >> userInput;
if(userInput == 1) playerLocation = 4;
else if(userInput == 2) playerLocation = 5;
}
if(playerLocation == 2) {
if(itemPickedUp2 == 0){
cout << "You arrive in a vast, barren, freezing landscape.\n";
cout << "You follow the road and see a fellow dead wanderer with rusted armor.\n";
cout << "Do you pick it up and continue?\n 1: Yes\n 2: No, but continue.\n 3: Turn back to Gurdenport\n";
cout << "\n";
cin >> userInput;
if(userInput == 1) {
playerItems[playerItemCount][0] = 3;
playerItems[playerItemCount][1] = 2;
playerItems[playerItemCount][3] = 3;
playerItemCount++;
itemPickedUp2 = 1;
playerLocation = 6;
}
else if(userInput == 2) playerLocation = 6;
}
else if(itemPickedUp2 == 1){
cout << "You arrive in a vast, barren, freezing landscape.\n";
cout << "What do you do?\n 1: Keep going south\n 2: Turn back to Gurdenport\n";
cin >> userInput;
if(userInput == 1) playerLocation = 6;
else if(userInput == 2) playerLocation = 1;
}
}
if(playerLocation == 4){
if(itemPickedUp4 == 0){
cout << "You get a full nights rest.\n"; 
cout << "The next morning, you walk into the snowy forest full of giant evergreens.\n";
cout << "You see a dead body with some rusted armor.\n";
cout << "Do you pick it up and continue or turn back?\n 1: Yes\n 2: No\n 3: Turn back to Novgorod\n";
cin >> userInput;
if(userInput == 1){
playerItems[playerItemCount][0] = 3;
playerItems[playerItemCount][1] = 2;
playerItems[playerItemCount][3] = 3;
playerItemCount++;
itemPickedUp4 = 1;
playerLocation = 7;
}
else if(userInput == 2) playerLocation = 7;
else if(userInput == 3) playerLocation = 3;
}
}
return 0;
}
}
running = 0;
}
return 0;
titleFunc(); {
cout << "\t\t\t\t---Hero of Golar: Part 1---\n\n\n";
cout << "\t\t\t\t   1: Play\n";
cin >> userInput;
if(userInput == 1){
void newGameFunc();
}
else{
running = 0;
}
return 0;
}
return 0;
}


Sorry for the untidy code but it's my first time coding something more than 20 lines long.

Any help would be greatly appreciated!
Thanks!
> Sorry for the untidy code
Indent your code.


You can't have a function definition inside another function definition
So you are not defining any function
Neither you are calling them
http://www.cplusplus.com/doc/tutorial/functions/


Edit:
string playerName = 0;
http://www.cplusplus.com/reference/string/string/string/
from c-string
Copies the null-terminated character sequence (C-string) pointed by s.
¿do you realize why it crashes?
Last edited on
Thanks a lot! i just got rid of the function all together since it wasn't necessary.

Also, the code was indented before, its just that i surpassed the maximum character limit.
Topic archived. No new replies allowed.