i dont know how to fix a runtime error


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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;





struct ITEM  // used for item varification. if player has an item, that item will be TRUE, thus he/she cannot have anymore
{
       //beginning weapons (not buyable) 
       bool wooden_stick;
       bool wooden_sword;
       bool sling_shot; 
       bool pellets;
       bool knife;
       bool sword;
       bool axe;
       bool wand_f;
       bool wand_e;
       bool wand_w;
       bool wand_a;
       bool staff;
       bool cell_phone;
       //middle (* means buyable) lvl 5+
       bool iron_sword; //*
       bool long_sword; //+
       bool hunting_bow; //* 
       bool long_bow;
       bool steel_sword;
       bool katana; //*
       bool ninjato; //*
       bool throwing_knives; //*
       bool kunai; //*
       bool shuriken; //*
       bool arrows; //*
       bool cleaver; //*
};
       

struct WORLD  //mainly location purposes
{
       string city;
       int location;
};

struct NPC //player and other NPCs
{
       int hp;
       int mp;
       int lvl;
       int exp;
       int maxhp;
       int maxmp;
       int maxexp;
       int SPD;
       int DEF;
       int AGI;
       int INT;
       int allignment; //alignment scale is 0-100, 100 being good and 0 being evil. 50 is nuetral.
       bool equipped;
       string sequipped;
}; 

struct BAG //player inventory
{
       bool bs1;
       string ss1;
       int is1;
       bool bs2;
       string ss2;
       int is2;
       bool bs3;
       string ss3;
       int is3;
       bool bs4;
       string ss4;
       int is4;
       bool bs5;
       string ss5;
       int is5;
       bool bs6;
       string ss6;
       int is6;
       bool bs7;
       string ss7;
       int is7;
       bool bs8;
       string ss8;
       int is8;
       bool bs9;
       string ss9;
       int is9;
       bool bs10;
       string ss10;
       int is10;
       bool bs11;
       string ss11;
       int is11;
       bool bs12;
       string ss12;
       int is12;
       bool bs13;
       string ss13;
       int is13;
       bool bs14;
       string ss14;
       int is14;
       bool bs15;
       string ss15;
       int is15;
       int gold;
};

struct SPECIAL //player's special items that dont go into inventory
{
       bool bp1;
       string sp1;
       bool bp2;
       string sp2;
       bool bp3;
       string sp3;
       bool bp4;
       string sp4;
       bool bp5;
       string sp5;
};

int pname();
int prace();

int main(NPC& Player, BAG& INV, SPECIAL& item, WORLD& game, ITEM& every) //type NPC name Player, type BAG name INV, type SPECIAL name item, type WORLD name game, type ITEM name every.
{
    
    game.location=1; //the players location on the "MAP"
    game.city="Fallory Town"; // location name. 
    string INPUT; // for everything the player will say/do
    cout<<"Gerald: Hello. What's your name?"<<endl;
    char NAME[30]; 
    cin>>NAME; //player says his/her name
    cout<<"\nGerald: Oh, so your name is "<<NAME<<".\n"<<endl;
    cout<<"Gerald: So what's your race? Elf, Human, or Dwarf?\n"<<endl;
    prace(); //execute function "prace()"
    cout<<"\nGerald: Well, "<<NAME<<", we seem to be having some trouble in our lovely realm.\nThe Volsorac are trying to take over the Middle Earth. And it's my job to find\nout why. How 'bout you go look around town while i go to work. Here, take this\nand I'll call you later.\n"<<endl;
    cout<<"* Say !take cellphone! *\n"<<endl;
    cin>>INPUT;
    if(INPUT=="!take cellphone!") //if player said !take cellphone!
    {
     while(item.bp1=0) // special items spot 1 is empty and the player does not have a cellphone 
     {
                    item.bp1=true; // make spot 1 true
                    item.sp1="cell phone"; //if the player wants to see what he has
                    every.cell_phone=true; //player HAS a cell phone
                    break;
     };
    };
    cout<<"\n\a\a* You Have Obtained A Cellphone! Now People Can Call You Where Ever You Are! *\a\a\n"<<endl;
    cout<<"\nYou Are In Fallory Town. Known For It's Schools In MAGIC At The Very Center Of\nThe City, It's Battle School For Warriors In Ever Corner, And It's Blacksmiths, Who Graceously Accept New Apprentices. You Will Have A Chance To Choose A School, But For Now You Must Get Acquainted With The Townspeople.\n"<<endl;  
    system("PAUSE");
}

void ELF(NPC& Player)
{
       Player.hp=60;
       Player.mp=15;
       Player.lvl=1;
       Player.exp=0;
       Player.maxhp=60;
       Player.maxmp=15;
       Player.maxexp=100;
       Player.SPD=7;
       Player.DEF=5;
       Player.AGI=6;
       Player.INT=7;
       Player.allignment=55; //alignment scale is 0-100, 100 being good and 0 being evil. 50 is nuetral.
}
    
void HUMAN(NPC& Player)
{
       Player.hp=50;
       Player.mp=10;
       Player.lvl=1;
       Player.exp=0;
       Player.maxhp=50;
       Player.maxmp=10;
       Player.maxexp=100;
       Player.SPD=6;
       Player.DEF=7;
       Player.AGI=6;
       Player.INT=5;
       Player.allignment=50; //alignment scale is 0-100, 100 being good and 0 being evil. 50 is nuetral.
}
    
void DWARF(NPC& Player)
{
       Player.hp=55;
       Player.mp=10;
       Player.lvl=1;
       Player.exp=0;
       Player.maxhp=55;
       Player.maxmp=10;
       Player.maxexp=100;
       Player.SPD=6;
       Player.DEF=8;
       Player.AGI=5;
       Player.INT=6;
       Player.allignment=50; //alignment scale is 0-100, 100 being good and 0 being evil. 50 is nuetral.
}
    
      
int prace()
{
    string PRACE;
    string PRACEELF="elf";
    string PRACEHUMAN="human";
    string PRACEDWARF="dwarf";
    cin>>PRACE;
    if(PRACE==PRACEELF)
    {
                         void ELF();
                         cout<<"\nElves are masters of magic, and live their lives studying and practicing in\nhopes to bring magic back to it's former glory and balance."<<endl;
    }
    
    else if(PRACE==PRACEHUMAN)
    {
                         void HUMAN();
                         cout<<"\nHumans live in fear of the Volsorac, an evil race bent on taking over Middle Earth. They mark fantastic mages and even better warriors."<<endl;
    }
    
    else if(PRACE==PRACEDWARF)
    {
                         void DWARF();
                         cout<<"\nDwarfs are short mountain people, known for their mastery over metal. They are the greatest warriors known."<<endl;
    }
    else if(PRACE!=PRACEELF || PRACE!=PRACEHUMAN || PRACE!=PRACEDWARF)
    {
        cout<<"Invalid Response. Try Again\n";
        prace();
    }
}


i read that runtime errors can be strings being overloaded or something (they mentioned stacks and then strings a lot) but from i can see, i dont know if i did that...

also i'm using DEV C++
Last edited on
Your main() function is your entry point into the program.
You do not define it like that.

What do you think you're achieving or want to achieve by writing your line 133 like that?
If you want to allow arguments to be passed to your function you will have to define main as int main(int argc, char* argv[]). argc contains the number of arguments and argv gives you array access to the string arguments.

1
2
3
4
5
6
7
8
9
#include <iostream>

int main(int argc, char* argv[])
{
	for (int i = 0; i < argc; ++i)
	{
		std::cout << argv[i] << std::endl;
	}
}


Note that the first argument is always the program path.
Topic archived. No new replies allowed.