Runtime

Ok, im making a game and I get an error that is unknown to me, <filename>.exe has stopped working. This application requested the runtime to terminate in an unusual way. Im using dev C++. Sorry for the long post and sloppy code. Don't steal my idea! aha!
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#include <iostream>
#include <math.h>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
//vars
//travel
int x = -8;
int y = 8;
int tx = 0;
int ty = 0;
string location = 0;
int refresh;
//travel
string name;
int option = 0;
float $ = 0;
      //needs
      int blood = 100;
      int contiousness = 100;
      int energy = 100;
      int sanity = 100;
      int bladder = 0;
      int hunger = 100;
      int pain = 0;
      
      //needs
    //in-game items
    int bootknifeslot = 0;
    int lefthandgunlegstrap = 0;
    int righthandgunlegstrap = 0;
        //Mags
        int mag1 = 0;
        int mag2 = 0;
        int mag3 = 0;
        int mag4 = 0;
        int mag5 = 0;
        int mag6 = 0;
        int mag7 = 0;
        int mag8 = 0;
        int mag9 = 0;
        int mag0 = 0;
        //mags
    int currentvehicle = 0;
    //body armor
    int helmet = 0;
    int chestplate = 0;
    int leggings = 0;
    int boots = 0;
        //grenade belt
        int grenade1 = 0;
        int grenade2 = 0;
        int grenade3 = 0;
        int grenade4 = 0;
        //grenade belt
        //address book
        bool Fredrika = 0;
        bool Jeff = 0;
        bool Galenos = 0;
        bool Rod = 0;
        bool Sophus = 0;
        bool Tina = 0;
        bool Essi = 0;
        bool Giorgi = 0;
        //address book
    int weaponstrap = 0;
    //in-game items
//vars
cout<< "Submit gamer tag:\n";
cin>> name;
cout<< "       It's July 12, 2020. 2:27am. You awaken happy that things have\nfinally returned to normal after what happened 5 years ago.\nStill the military snoop around trying to find it but no one\nis in harm and nothing has died since 2018. Now I think about\nhow the atmosphere had changed when it started to now. From that\nperiod of time the music stopped playing, quiet became obnoxious\nbut there was something else that was missing, life had";
cout<< "\n\nNostrobe\n";
cin.get();
cin.ignore();
cout<< "      You can not seem to fall asleep so you decide to watch tv.\nYou are alarmed to find that the toxin created in 2017 has no effect.\nYou have prepared for a day where you will have to face\nwhat you already have before. You enter your equipment room...\nTurorial added (1)\nDouble barreled shotgun added (1)\nMi911 added (1)\nAmmo added(30)\nCell phone added (1)\nTo open your inventory, select 1\n1: Open inventory\n";
sel1:
cin>> option;
if (option != 1) goto sel1;
if (option == 1) goto inventory;
//inventory GUI
inventory:
//boot knives
if (bootknifeslot > 0) (cout<< "\nKnife Slot:\n");
//Gun straps left
if (lefthandgunlegstrap > 0) (cout<< "\nLeft leg strap\n:");
//right
if (righthandgunlegstrap > 0) (cout<< "\nRight leg strap:\n");
//mags
if (mag1 > 0) (cout<< "\nMagazine slot 1:\n");
if (mag1 > 0) (cout<< mag1);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 2:\n");
if (mag1 > 0) (cout<< mag2);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 3:\n");
if (mag1 > 0) (cout<< mag3);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 4:\n");
if (mag1 > 0) (cout<< mag4);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 5:\n");
if (mag1 > 0) (cout<< mag5);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 6:\n");
if (mag1 > 0) (cout<< mag6);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 7:\n");
if (mag1 > 0) (cout<< mag7);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 8:\n");
if (mag1 > 0) (cout<< mag8);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 9:\n");
if (mag1 > 0) (cout<< mag9);
if (mag1 > 0) (cout<< "\n");
if (mag1 > 0) (cout<< "\nMagazine slot 0:\n");
if (mag1 > 0) (cout<< mag0);
if (mag1 > 0) (cout<< "\n");
//body armor
if (helmet > 0) (cout<< "\nHelmet:\n");
if (chestplate > 0) (cout<< "\nChestplate:\n");
if (leggings > 0) (cout<< "\nLeggings:\n");
if (boots > 0) (cout<< "\nBoots:\n");
//grenades
if (grenade1 > 0) (cout<< "\nGrenade slot 1:\n");
if (grenade2 > 0) (cout<< "\nGrenade slot 2:\n");
if (grenade3 > 0) (cout<< "\nGrenade slot 3:\n");
if (grenade4 > 0) (cout<< "\nGrenade slot 4:\n");
//weaponstrap
if (weaponstrap > 0) (cout<< "\nWeapon backstrap:\n");
//guide
cout<< "\n0: Tutorial\n";
cout<< "\n1: Address book\n";
cin>> option;
//calc
if (option == 0) goto tutorial;
if (option == 1) goto addressbook;
goto inventory;
//tutorial
tutorial:
cout<< "\nIts happening again, the appocalypse! Didn't it already happen? Yes\nbut it didn't completely end, this appocalypse is the aftermath!\nIs your sanity running low? Its an in-game variable!\nYou do not want this to run low for obvious reasons.\nBlood is important, bleed out and you will die.\nBeing contious is a good thing, stay alert and stay safe!\nEat when you need to or you can die, eat to mutch and no, you wont get fat\nY     ou will have other effects.\nSleep when you must or you might pas out naturally!\nPain hurts, stay out of trouble!\nRemember to go when you have to! We don't want any accidents.\nThats it for body maintainence, enter your input from the options do select something.\nThats it, try to survive!\n";
cin.get();
cin.ignore();
goto inventory;
//tutorial
//address book
addressbook:
cout<< "\n0: Amrit Stanford 08,04\n";
if (Fredrika == 1) (cout<< "\n1: Fredrika Street 01,01\n");
if (Jeff == 1) (cout<< "\n2: Jeff Loc 03,03\n");
if (Galenos == 1) (cout<< "\n3: Galenos Martell 05,01\n");
if (Rod == 1) (cout<< "\n4: Rod Habicht 01,05\n");
if (Sophus == 1) ("\n5: Sophus Kelogg 06,05\n");
if (Tina == 1) ("\n6: Tina Lamouchi 06,01\n");
if (Essi == 1) ("\n7: Essi Belloni 04,07\n");
if (Giorgi == 1) ("\n8: Giorgi Gully 12,00\n");
cin>> option;
if (option == 0) goto travel;
if (option == 1 and Fredrika == 1) goto travel;
if (option == 2 and Jeff ==1) goto travel;
if (option == 3 and Galenos == 1) goto travel;
if (option == 4 and Rod == 1) goto travel;
if (option == 5 and Sophus == 1) goto travel;
if (option == 6 and Tina == 1) goto travel;
if (option == 7 and Essi == 1) goto travel;
if (option == 8 and Giorgi == 1) goto travel;
goto inventory;
//addres book
Amrit:
cout<< "End of travel!";
cin.get();
cin.ignore();
Fredrika:
Jeff:
Galenos:
Rod:
Sophus:
Tina:
Essi:
Giorgi:
//travel
travel:
cout<< "\nTravelling...\n";
if (option == 0) (tx = -8);
if (option == 0) (ty = 4);
if (option == 0) (location = "Amrit");
refresh = x - tx + y - ty;
goto refresh;
refresh:
refresh = refresh - 1;
energy = energy - 1;
bladder = bladder + 1;
hunger = hunger - 1;
pain = pain - 1;
contiousness = contiousness + 1;
sanity = sanity + 1;
blood = blood + 1;
if (energy < 1) (cout<< "\nYou passed out.\n");
if (energy < 1) (refresh = refresh + 50);
if (energy < 1) (energy = energy + 50);
if (bladder > 99) (cout<< "\nYou accedentally dropped fecal.\n");
if (bladder > 99) (bladder = 0);
if (hunger < 1) (cout<< "\nYou starved to death.\n");
if (hunger < 1) goto death;
if (pain < 0) (pain = 0);
if (contiousness > 100) (contiousness = 100);
if (sanity > 100) (sanity = 100);
if (blood > 100) (blood = 100);
if (refresh > 0) goto refresh;
death:
cout<< "\nGame over.\n";
cin.get();
cin.ignore();
}
I don't know how your program ran to the point of terminating unexpectectedly.
The code you posted won't even compile.

Line 163-170. The proper condition is && unless <ciso646> is included.

Line 16 will cause a run-time exception. You can't assign a null pointer to a string.

Removing the "= 0" from line 16 and the program at least gets to the welcome screen.

Edit to add reference to <ciso646>.
Last edited on
> Line 163-170. The proper condition is &&
`and' is perfectly valid
http://www.cplusplus.com/reference/ciso646/
Last edited on
@ne555 - Thanks for the correction. However, those macros are only valid if <ciso646> is included, which the OP did not include. Edited previous post to clarify.
Last edited on
Read again
> In C++, reserved words exist with the same names as these macros
> Therefore the inclusion of this header has no effect in C++
> and is not necessary in order to use the alternative names.
@abstractionanon Yes it did compile sucessfully. Thanks for the proper ands! I didn't know the proper ands so i put and. Putting 0 for a string will cause a problem? Actually makes sense! I just added the address book and travel options. There will be a problem in there. I will correct the code and if it does not work then i will #include <cisco646> i never heard of that file before but...
@abstractionanon It was because I assigned 0 to the string. None of the other stuff caused the problem so you solved it! Thanks! I had no idea assigning 0 to a string would cause the problem but yet again my compiler gets angry at me when I assign numbers!
Topic archived. No new replies allowed.