text-based RPG

hello again everybody. I've been working on a RPG that saves what the user inputs to a file that the user gives the name for, but when it gets to the end of the code, the program just stops. I have tried to remedy this, but nothing that i have found has worked.

here is the code:
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
#include <time.h>
#include <cstdlib>
using namespace std;

void setcolor(unsigned short color)                 //The function that you'll use to
{                                                   //set the colour
    HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hcon,color);
}


int main()
{

	int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,strength, dexterity, constitution, intelligence, wisdom, charisma;

	string charclass, race, alignment, gender, str1, str2, str3, str4, str5, str6, str7, str8, str9;

	char name[10], alias[10], charname[10];

	str8 = "yes";
	str9 = "no";
	b = 1;
	c = 0;

	cout << "Welcome to Crimson Moon." << endl << endl;
	system ("pause");
	system ("CLS");

	cout << "Greetings adventurer, it isn't worth my time to\n remember who has visited here before, so I'm going to ask if\n you already have a name and an alias.\n" << endl;
	cout << "So, do you have a name and an alias? (yes/no)";
	cin >> str7;

	if (str7.compare(str8) == 0)
	{
		cout << "Ok, then please tell me your name.\n\n And do be quick about it, I dont have all day.\n";
		cin >> charname;
		
		

		ifstream character (charname);
		if (character.is_open())
		{
		cout << "The file is working";
		system ("pause");
		}
		else 
		{cout << "The file is not working or does not exist.";
		system ("pause");
		}


	}

	

	else if (str7.compare(str9) == 0)
	{
		system ("CLS");
		cout << " Ok, please tell me your name. Oh, please put a '.cpp' at the end of your name." << endl;
		cin >> name;
		b = 2;
		c += 1;
		ofstream character (name);
		if (character.is_open())
		{
		cout << "File opened";
		while (c != 7)
		{
		
		if (b == 2)
		{
			system("CLS");
		cout << "Now your alias, please." << endl;
		cin >> alias;
		b = 3;
		c += 1;
		}
		else if (b == 3)
		{
			system("CLS");
		cout << "If you dont mind me asking, what race are you..." << endl;
		cin >> race;
		b = 4;
		c += 1;
		}
		else if (b == 4)
		{
			system("CLS");
		cout << "...and what is your gender?" << endl;
		cin >> gender;
		b = 5;
		c += 1;
		}
		else if (b == 5)
		{
		system ("pause");
		system ("CLS");
		cout << "Thank you for your patience, we are almost done." << endl << "Now, what is your alignment?" << endl;
		cout << "1 - Good\n2 - Evil\n3 - Lawful\n4 - Chaotic\n5 - Lawful Good\n6 - Lawful Evil\n7 - Chaotic Good\n8 - Chaotic Evil\n9 - Help\n";
		cin >> a;
		if (a == 1)
		{alignment = "Good";
		b = 6;
		c += 1;}
		else if (a == 2)
		{alignment = "Evil";
		b = 6;
		c += 1;}
		else if (a == 3)
		{alignment = "Lawful";
		b = 6;
		c += 1;}
		else if (a == 4)
		{alignment = "Chaotic";
		b = 6;
		c += 1;}
		else if (a == 5)
		{alignment = "Lawful Good";
		b = 6;
		c += 1;}
		else if (a == 6)
		{alignment = "Lawful Evil";
		b = 6;
		c += 1;}
		else if (a == 7)
		{alignment = "Chaotic Good";
		b = 6;
		c += 1;}
		else if (a == 8)
		{alignment = "Chaotic Evil";
		b = 6;
		c += 1;}
		else if (a == 9)
		{}
		else 
		{system ("CLS");
		cout << "Come on, get with the program! Dx";}
		}
		else if (b == 6)
		{
			system("CLS");
			cout << "Now that all that is out of the way we can get to the exciting part...\n well sorta, you dont get to fight anything yet." << endl;
			system ("pause");
			system ("CLS");
			cout << "Ok, what would you like your class to be?\n1 - Barbarian\n2 - Bard\n3 - Cleric\n4 - Druid\n5 - Fighter\n6 - Monk\n7 - Paladin\n8 - Ranger\n9 - Rogue\n10 - Sorceror\n11 - Wizard\n12 - Help\n";
			cin >> d;
			if (d == 1)
			{
			charclass = "Barbarian";
			strength = 16;
			dexterity = 14;
			constitution = 18;
			intelligence = 10;
			wisdom = 14;
			charisma = 12;
			b += 1;
			c += 1;
			}
			else if (d == 2)
			{
			charclass = "Bard";
			strength = 14;
			dexterity = 18;
			constitution = 14;
			intelligence = 12;
			wisdom = 10;
			charisma = 16;
			b += 1;
			c += 1;
			}
			else if (d == 3)
			{
			charclass = "Cleric";
			strength = 14;
			dexterity = 14;
			constitution = 12;
			intelligence = 10;
			wisdom = 18;
			charisma = 16;
			b += 1;
			c += 1;
			}
			else if (d == 4)
			{
			charclass = "Druid";
			strength = 12;
			dexterity = 14;
			constitution = 14;
			intelligence = 10;
			wisdom = 18;
			charisma = 16;
			b += 1;
			c += 1;
			}
			else if (d == 5)
			{
			charclass = "Fighter";
			strength = 18;
			dexterity = 14;
			constitution = 16;
			intelligence = 14;
			wisdom = 10;
			charisma = 12;
			b += 1;
			c += 1;
			}
			else if (d == 6)
			{
			charclass = "Monk";
			strength = 14;
			dexterity = 16;
			constitution = 12;
			intelligence = 14;
			wisdom = 18;
			charisma = 10;
			b += 1;
			c += 1;
			}
			else if (d == 7)
			{
			charclass = "Paladin";
			strength = 14;
			dexterity = 12;
			constitution = 14;
			intelligence = 10;
			wisdom = 16;
			charisma = 18;
			b += 1;
			c += 1;
			}
			else if (d == 8)
			{
			charclass = "Ranger";
			strength = 14;
			dexterity = 16;
			constitution = 10;
			intelligence = 12;
			wisdom = 18;
			charisma = 14;
			b += 1;
			c += 1;
			}
			else if (d == 9)
			{
			charclass = "Rogue";
			strength = 12;
			dexterity = 18;
			constitution = 14;
			intelligence = 16;
			wisdom = 10;
			charisma = 14;
			b += 1;
			c += 1;
			}
			else if (d == 10)
			{
			charclass = "Sorceror";
			strength = 12;
			dexterity = 14;
			constitution = 10;
			intelligence = 14;
			wisdom = 16;
			charisma = 18;
			b += 1;
			c += 1;
			}
			else if (d == 11)
			{
			charclass = "Wizard";
			strength = 10;
			dexterity = 14;
			constitution = 14;
			intelligence = 18;
			wisdom = 16;
			charisma = 12;
			b += 1;
			c += 1;
			}
			else if (d == 12)
			{}
			
			else 
			{
			system ("CLS");
			cout << "Are you an idiot or something? Enter a number between 1 and 12 you moron! Dx";
			}
			}
			}
			
			
			
			
			
			}
			
			}

			cout << "Hello";


return 0;

}


as usual, thanks in advance ^_^
You start a while loop on line 72 of your program.
while (c != 7)
Apparently your program never allows this to evaluate to false.
ok, that makes sense that it would cause an unending line of death.

what would you suggest that i replace that while loop with to get my program to actually work?
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
#include <time.h>
#include <cstdlib>
using namespace std;

void setcolor(unsigned short color)                 //The function that you'll use to
{                                                   //set the colour
    HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hcon,color);
}


int main()
{

	int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,strength, dexterity, constitution, intelligence, wisdom, charisma;

	string name, alias, charclass, race, alignment, gender, str1, str2, str3, str4, str5, str6, str7, str8, str9;

	char charname[10];

	str8 = "yes";
	str9 = "no";
	b = 1;
	c = 0;

	cout << "Welcome to Crimson Moon." << endl << endl;
	system ("pause");
	system ("CLS");

	cout << "Greetings adventurer, it isn't worth my time to\n remember who has visited here before, so I'm going to ask if\n you already have a name and an alias.\n" << endl;
	cout << "So, do you have a name and an alias? (yes/no)";
	cin >> str7;

	if (str7.compare(str8) == 0)
	{
		cout << "Ok, then please tell me your name.\n\n And do be quick about it, I dont have all day.\n";
		cin >> charname;
		
		

		ifstream character (charname);
		if (character.is_open())
		{
		cout << "The file is working\n";
		system("pause");
		getline(character,alias);
		cout << alias << endl;
		system("pause");
		getline(character,race);
		cout << race << endl;
		system("pause");
		getline(character,gender);
		cout << gender << endl;
		system("pause");
		getline(character,alignment);
		cout << alignment << endl;
		system("pause");
		getline(character,charclass);	
		cout << charclass << endl;
		system("pause");
		character.close();
		}
		else 
		{cout << "The file is not working or does not exist.";
		system ("pause");
		}

		system("pause");
		return 0;


	}

	

	else if (str7.compare(str9) == 0)
	{
		system ("CLS");
		cout << " Ok, please tell me your name. Oh, please put a '.cpp' at the end of your name." << endl;
		cin >> charname;
		b = 2;
		
	}
		ofstream character (charname);
		if (character.is_open())
		{
		cout << "File opened";
		while (c != 2)
		{
		
		if (b == 2)
		{
			system("CLS");
		cout << "Now your alias, please." << endl;
		cin >> alias;
		b = 3;
		
		}
		else if (b == 3)
		{
			system("CLS");
		cout << "If you dont mind me asking, what race are you..." << endl;
		cout << "1 - Human\n2 - Elf\n3 - Half-Elf\n4 - Gnome\n5 - Dwarf\n6 - Halfling\n7 - Half-Orc\n";
		cin >> e;
		if (e == 1)
		{
		race = "Human";
		b = 4;
		}
		else if (e == 2)
		{
		race = "Elf";
		b = 4;
		}
		else if (e == 3)
		{
		race = "Half-Elf";
		b = 4;
		}
		else if (e == 4)
		{
		race = "Gnome";
		b = 4;
		}
		else if (e == 5)
		{
		race = "Dwarf";
		b = 4;
		}
		else if (e == 6)
		{
		race = "Halfling";
		b = 4;
		}
		else if (e == 7)
		{
		race = "Half-Orc";
		b = 4;
		}
		else 
		{
		system("CLS");
		cout << "Oh my lord! Ok, look. It's simple, you dont have to think much.\nYou push a key that has a number on it that is between\nthe number one, and the number seven.\nDO IT RIGHT THIS TIME!!!!\n";
		system("pause");
		}

		
		}
		else if (b == 4)
		{
			system("CLS");
		cout << "...and what is your gender?\n1 - Male\n2 - Female" << endl;
		cin >> f;
		if (f == 1)
		{
		gender = "Male";
		b = 5;
		}
		else if (f == 2)
		{
		gender = "Female";
		b = 5;
		}
		else 
		{
		system("CLS");
		cout << "Of all the days that I'm called in to do this,\nwhy does it have to be during the flood of idiots?\nYou either press the number '1', or the number '2',\nit really isn't that hard.\n";
		system("pause");
		}
		
		
		}
		else if (b == 5)
		{
		system ("pause");
		system ("CLS");
		cout << "Thank you for your patience, we are almost done." << endl << "Now, what is your alignment?" << endl;
		cout << "1 - Good\n2 - Evil\n3 - Lawful\n4 - Chaotic\n5 - Lawful Good\n6 - Lawful Evil\n7 - Chaotic Good\n8 - Chaotic Evil\n9 - Help\n";
		cin >> a;
		if (a == 1)
		{alignment = "Good";
		b = 6;
		}
		else if (a == 2)
		{alignment = "Evil";
		b = 6;
		}
		else if (a == 3)
		{alignment = "Lawful";
		b = 6;
		}
		else if (a == 4)
		{alignment = "Chaotic";
		b = 6;
		}
		else if (a == 5)
		{alignment = "Lawful Good";
		b = 6;
		}
		else if (a == 6)
		{alignment = "Lawful Evil";
		b = 6;
		}
		else if (a == 7)
		{alignment = "Chaotic Good";
		b = 6;
		}
		else if (a == 8)
		{alignment = "Chaotic Evil";
		b = 6;
		}
		else if (a == 9)
		{}
		else 
		{system ("CLS");
		cout << "Come on, get with the program! Dx";}
		}
		else if (b == 6)
		{
			system("CLS");
			cout << "Now that all that is out of the way we can get to the exciting part...\n well sorta, you dont get to fight anything yet." << endl;
			system ("pause");
			system ("CLS");
			cout << "Ok, what would you like your class to be?\n1 - Barbarian\n2 - Bard\n3 - Cleric\n4 - Druid\n5 - Fighter\n6 - Monk\n7 - Paladin\n8 - Ranger\n9 - Rogue\n10 - Sorceror\n11 - Wizard\n12 - Help\n";
			cin >> d;
			if (d == 1)
			{
			charclass = "Barbarian";
			strength = 16;
			dexterity = 14;
			constitution = 18;
			intelligence = 10;
			wisdom = 14;
			charisma = 12;
			b += 1;
			c = 2;
			}
			else if (d == 2)
			{
			charclass = "Bard";
			strength = 14;
			dexterity = 18;
			constitution = 14;
			intelligence = 12;
			wisdom = 10;
			charisma = 16;
			b += 1;
			c = 2;
			}
			else if (d == 3)
			{
			charclass = "Cleric";
			strength = 14;
			dexterity = 14;
			constitution = 12;
			intelligence = 10;
			wisdom = 18;
			charisma = 16;
			b += 1;
			c = 2;
			}
			else if (d == 4)
			{
			charclass = "Druid";
			strength = 12;
			dexterity = 14;
			constitution = 14;
			intelligence = 10;
			wisdom = 18;
			charisma = 16;
			b += 1;
			c = 2;
			}
			else if (d == 5)
			{
			charclass = "Fighter";
			strength = 18;
			dexterity = 14;
			constitution = 16;
			intelligence = 14;
			wisdom = 10;
			charisma = 12;
			b += 1;
			c = 2;
			}
			else if (d == 6)
			{
			charclass = "Monk";
			strength = 14;
			dexterity = 16;
			constitution = 12;
			intelligence = 14;
			wisdom = 18;
			charisma = 10;
			b += 1;
			c = 2;
			}
			else if (d == 7)
			{
			charclass = "Paladin";
			strength = 14;
			dexterity = 12;
			constitution = 14;
			intelligence = 10;
			wisdom = 16;
			charisma = 18;
			b += 1;
			c = 2;
			}
			else if (d == 8)
			{
			charclass = "Ranger";
			strength = 14;
			dexterity = 16;
			constitution = 10;
			intelligence = 12;
			wisdom = 18;
			charisma = 14;
			b += 1;
			c = 2;
			}
			else if (d == 9)
			{
			charclass = "Rogue";
			strength = 12;
			dexterity = 18;
			constitution = 14;
			intelligence = 16;
			wisdom = 10;
			charisma = 14;
			b += 1;
			c = 2;
			}
			else if (d == 10)
			{
			charclass = "Sorceror";
			strength = 12;
			dexterity = 14;
			constitution = 10;
			intelligence = 14;
			wisdom = 16;
			charisma = 18;
			b += 1;
			c = 2;
			}
			else if (d == 11)
			{
			charclass = "Wizard";
			strength = 10;
			dexterity = 14;
			constitution = 14;
			intelligence = 18;
			wisdom = 16;
			charisma = 12;
			b += 1;
			c = 2;
			}
			else if (d == 12)
			{}
			
			else 
			{
			system ("CLS");
			cout << "Are you an idiot or something? Enter a number between 1 and 12 you moron! Dx";
			}
			c = 2;}
			character << alias << endl;
			character << race << endl;
			character << gender << endl;
			character << alignment << endl;
			character << charclass << endl;
			character.close();
			}
			
			
			
			
			
			}
			return 0;
			}

			

above is my reworked code, and as you can see, it is getting pretty hefty, i couldnt post it with this message because it went over the limit.

i have worked out the kinks with the program writing the file, now i just have a problem with it reading the strings in the file.
it will read the first string, the "alias" one, and display its contents, but it doesnt register any of the other strings. what did i do wrong?
Topic archived. No new replies allowed.