Want to output results from a Function

HI guys, after outputting the Function..
Its just after the switch
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
Function List :
//Describes, by printing out, the Monsters origin stats.
//Function for each, will then create one that assimilates them all.
int DescribeMonOrigin1();
void DescribeMonOrigin2();
void DescribeMonOrigin3();
void DescribeMonOrigin4();
void DescribeMonOrigin5();
//Full Describe Function ( Made up of 1-5)
void FullOriginDescribe();

Random Gen Function :
void GenerateOrigin()
//Generates the Monsters Origin Stats.
{
	RandomNum = (rand() % 9) + 1;
	MonstersBase[0] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[1] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[2] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[3] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[4] = RandomNum;

Lookup Function:
void DescribeMonOrigin1()
//Body Number
{
	if (MonstersBase[0] == 0)
	{
		cout << " MUTATION : Its body is covered with hardened scales." << endl;
		MonMAXHP + 15;
	}
	if (MonstersBase[0] == 1)
	{
		cout << " It has an average build" << endl;
	}
	if (MonstersBase[0] == 2)
	{
		cout << " It has a thicker, heavyset build" << endl;
	}
	if (MonstersBase[0] == 3)
	{
		cout << " It has a taller, slender build" << endl;
	}
	if (MonstersBase[0] == 4)
	{
		cout << " MUTATION : It has softer, flexible skin" << endl;
		MonMAXHP - 5;
		MonSpeed + 10;
	}
	if (MonstersBase[0] == 5)
	{
		cout << " It has a short, stocky build" << endl;
	}
	if (MonstersBase[0] == 6)
	{
		cout << " It has tufts of fur over its body" << endl;
	}
	if (MonstersBase[0] == 7)
	{
		cout << " It has a stooped, musclebound posture" << endl;
		MonAtk + 10;
	}
	if (MonstersBase[0] == 8)
	{
		cout << " It carries a little extra weight" << endl;
	}
	if (MonstersBase[0] == 9)
	{
		cout << " MUTATION : It seesm to shine different hues in the light" << endl;
		MonDef + 20;
	}
}

Finally, The switch :
	cout << " Here is a switch, 1 tests the description engine" << endl;
	cin >> Switchnum;
	switch (Switchnum)
	{
	case 1:
		cout << FullOriginDescribe;
		cout << " FullOrigin Describe";
		cout << DescribeMonOrigin1;



Hi guys;
I'm a beginner and I decided to make a rough text based game with Functions, text and random number generation to try and learn C++.

It WAS all going ok, but I've run into a snag. I've got an array, with a function that fills it, then it checks what each element of the array is and will print out a line of text.
However I can't get it to print anything out, I seem to get nonsense, which, I'm assuming is the memory address..

I tried swapping it to an int function, but that didn't help, any ideas?

I also apologise for dumping all the code, but I'm not sure whats relevant, and what isn't.

Thanks for taking the time to look!
Last edited on
It would be better(at least for me) if you post all your code.
Line 84: Per line 10, FullOriginDescribe is a void function. You can't cout a void function. Since you don't show the implementation of that function, I can only assume that it outputs to cout and what you want here is a function call.
84
85
    //  Function call, not cout
    FullOriginDescribe ();


Line 86: Ditto.


Ahh, it still wont output it?
I'll lay the code out here, I'm sure its a simple mistake..
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
#include <iostream>
#include <string>
#include <random>
#include <stdio.h>
#include <time.h>

using namespace std;

//Generates Trainer ID
void GenerateID();
//Generates Original Stats
void GenerateOrigin();
//Generate Monster Gender


//Describes, by printing out, the Monsters origin stats.
//Function for each, will then create one that assimilates them all.
void DescribeMonOrigin1();
void DescribeMonOrigin2();
void DescribeMonOrigin3();
void DescribeMonOrigin4();
void DescribeMonOrigin5();
//Full Describe Function ( Made up of 1-5)
void FullOriginDescribe();

//For when random numbers are needed.
int RandomNum = 0;

//For the switch
int Switchnum = 0;

//Players Catch Level and XP
int PlayerCLevel = 1;
//Player Catch Level
int PlayerXP2 = 0;
//XP TO Next Level
int PlayerXP = 0;
//XP (In Total)
const int XPNeeded1k = 1000;
// XP needed to level will always be Levelnumber x 1000.

//Players Name
string Playername;
//Monsters Name
string Monstername;

//For creation of their first stats.
int MonstersBase[5]{0, 0, 0, 0, 0};
//Refers to
//Eyes
//Body Build
//Arms
//Legs
//Temperment

//Monster Stats
int MonMAXHP = 100;
int MonCHP = 0;
int MonAtk = 50;
int MonDef = 50;
int MonSpeed = 50;

//Monster Gender
int MonGender = 0;
bool MonF = 0;
bool MonM = 0;

//Full Genetic List
int MonsterGene[32];

//To detect players Gender.
int Gendernumber = 0;
bool Ismale = 0;
bool Isfem = 0;

//Players ID Code.
int PlayerID[5]{0, 0, 0, 0, 0}; // 4 Digits, last one is for Gender.
//EVEN is Male, ODD if female.

int main()
{

	//Seeding random from time.
	srand(time(NULL));

	cout << "Welcome player to Genemonsters, where random monsters are created," << endl;
	cout << "and their heritage tracked!" << endl;
	cout << ""<< endl;
	cout << ""<< endl;
	cout << " Firstly, we need to know some details about you!" << endl;
	cout << " Are you a Boy, Or A Girl?" << endl;
	cout << " 1 For Boy, 2 For Girl" << endl;
	cin >> Gendernumber;
	//Currently 1 is Male, else is Fem, easy to change, just cba.
	if (Gendernumber == 1)//If statement to choose player gender.
	{
		cout << " A Boy! Welcome!" << endl;
		Ismale = 1;
		Isfem = 0;
	}
	if (Gendernumber == 2)
	{
		cout << " A Girl! Welcome!" << endl;
		Isfem = 1;
		Ismale = 0;
	}
	if (Gendernumber ==! 1 || 2)
	{
		cout << "Incorrect input, please try again!" << endl;
	}
	cout << "Now that is out of the way, we need a name!" << endl;
	cout << "What is your name player?" << endl;
	cin >> Playername;
	GenerateID();
	cout << " Great! You are " << Playername << "!" << "Welcome" << endl;
	cout << " The final step is to name your Monster, choose wisely, it CANNOT be changed " << endl;
	cin >> Monstername;

** CONTINUES **

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
	GenerateOrigin();
	//Generate a Monsters Gender here. Function maybe?
	cout << " Great! You are " <<Playername << " with your partner " << Monstername << "! Welcome!" << endl;
	cout << " Your Genemonster adventure is about to begin!" << endl;
	cout << " ** THE ADVENTURE BEGINS ** " << endl;
	//Stylised loading
	cout << " ************************************************" << endl;
	cout << " <><><><><><><><><><><><><><><><>" << endl;
	cout << " ************************************************" << endl;
	//Testing Generation
	cout << " Here is a switch, 1 tests the description engine" << endl;
	cin >> Switchnum;
	switch (Switchnum)
	{
	case 1:
		FullOriginDescribe;
		cout << " FullOrigin Describe";
		cout << DescribeMonOrigin1;
		cout << "PlayerID" << endl;
		
		cout << " Here " << endl;
		cin>>Switchnum;
		break;

	case 2:

		break;

	case 3:

		break;

	default:

		break;
	}


}


void GenerateID()
//Generate the PlayersID. Even Male, Odd Female.
{
	srand(time(NULL));

	RandomNum = rand() % 9 + 1;
	PlayerID[0] = RandomNum;
	RandomNum = rand() % 9 + 1;
	PlayerID[1] = RandomNum;
	RandomNum = rand() % 9 + 1;
	PlayerID[2] = RandomNum;
	RandomNum = rand() % 9 + 1;
	PlayerID[3] = RandomNum;
	//Now for assigning the gender number.
	if (Ismale = 1)
	{
		RandomNum = 2 * rand();
		PlayerID[4] = RandomNum;
	}
	else
	{
		RandomNum = 2 * rand() + 1;
		PlayerID[4] = RandomNum;
	}
}

void GenerateOrigin()
//Generates the Monsters Origin Stats.
{
	RandomNum = (rand() % 9) + 1;
	MonstersBase[0] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[1] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[2] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[3] = RandomNum;
	RandomNum = (rand() % 9) + 1;
	MonstersBase[4] = RandomNum;
}

void DescribeMonOrigin1()
//Eye Colour
{
	if (MonstersBase[0] == 0)
	{
		cout << " It has fierce, red eyes" << endl;
	}
	if (MonstersBase[0] == 1)
	{
		cout << " It has shining, black eyes" << endl;
	}
	if (MonstersBase[0] == 2)
	{
		cout << " It has hauntingly beautiful blue eyes" << endl;
	}
	if (MonstersBase[0] == 3)
	{
		cout << " It has sunken, pure white eyes" << endl;
	}
	if (MonstersBase[0] == 4)
	{
		cout << " It has strange, electric green eyes" << endl;
	}
	if (MonstersBase[0] == 5)
	{
		cout << " It has vibrant, orange eyes" << endl;
	}
	if (MonstersBase[0] == 6)
	{
		cout << " It has a green and blue hetereochromatic eyes" << endl;
	}
	if (MonstersBase[0] == 7)
	{
		cout << " It has reflective, silver eyes" << endl;
	}
	if (MonstersBase[0] == 8)
	{
		cout << " It has brown and blue hetereochromatic eyes" << endl;
	}
	if (MonstersBase[0] == 9)
	{
		cout << " It has radiant, golden eyes" << endl;
	}
	return 0;
}

void DescribeMonOrigin2()
//Body Number
{
	if (MonstersBase[1] == 0)
	{
		cout << " MUTATION : Its body is covered with hardened scales." << endl;
		MonMAXHP + 15;
	}
	if (MonstersBase[1] == 1)
	{
		cout << " It has an average build" << endl;
	}
	if (MonstersBase[1] == 2)
	{
		cout << " It has a thicker, heavyset build" << endl;
	}
	if (MonstersBase[1] == 3)
	{
		cout << " It has a taller, slender build" << endl;
	}
	if (MonstersBase[1] == 4)
	{
		cout << " MUTATION : It has softer, flexible skin" << endl;
		MonMAXHP - 5;
		MonSpeed + 10;
	}
	if (MonstersBase[1] == 5)
	{
		cout << " It has a short, stocky build" << endl;
	}
	if (MonstersBase[1] == 6)
	{
		cout << " It has tufts of fur over its body" << endl;
	}
	if (MonstersBase[1] == 7)
	{
		cout << " It has a stooped, musclebound posture" << endl;
		MonAtk + 10;
	}
	if (MonstersBase[1] == 8)
	{
		cout << " It carries a little extra weight" << endl;
	}
	if (MonstersBase[1] == 9)
	{
		cout << " MUTATION : It seesm to shine different hues in the light" << endl;
		MonDef + 20;
	}
}

void DescribeMonOrigin3()
{
	if (MonstersBase[2] == 0)
	{
		cout << " Its arms are of slightly longer than average length" << endl;
	}
	if (MonstersBase[2] == 1)
	{
		cout << " MUTATION : Its nails are slightly hooked and crooked" << endl;
		MonAtk + 5;
	}
	if (MonstersBase[2] == 2)
	{
		cout << " Its arms are chunky, and thick" << endl;
		MonAtk + 2;
	}
	if (MonstersBase[2] == 3)
	{
		cout << " It has tufts of hair down its arms" << endl;
	}
	if (MonstersBase[2] == 4)
	{
		cout << " It has long fingers" << endl;
	}
	if (MonstersBase[2] == 5)
	{
		cout << " It has short fingers" << endl;
	}
	if (MonstersBase[2] == 6)
	{
		cout << " MUTATION : It has stumpy, calloused fingers" << endl;
		MonDef + 5;
	}
	if (MonstersBase[2] == 7)
	{
		cout << " Its hands are slightly darker than its body" << endl;
	}
	if (MonstersBase[2] == 8)
	{
		cout << " MUTATION : Its hands are of uneven size" << endl;
		MonAtk - 5;
	}
	if (MonstersBase[2] == 9)
	{
		cout << " Its hands are slightly lighter than its body" << endl;
	}
}

void DescribeMonOrigin4()
{
	if (MonstersBase[3] == 0)
	{
		cout << " It has squat, stumpy legs" << endl;
	}
	if (MonstersBase[3] == 1)
	{
		cout << " It has graceful, long legs" << endl;
	}
	if (MonstersBase[3] == 2)
	{
		cout << " MUTATION : Its legs bristle with tiny spines" << endl;
		MonAtk + 5;
		MonSpeed + 5;
	}
	if (MonstersBase[3] == 3)
	{
		cout << " MUTATION : Heavy, chittinous plates run all over the leg" << endl;
		MonSpeed - 5;
		MonMAXHP + 20;
	}
	if (MonstersBase[3] == 4)
	{
		cout << " Its knees bend both ways easily" << endl;
		MonSpeed + 5;
	}
	if (MonstersBase[3] == 5)
	{
		cout << " Its legs seem to twich, it cant stay still" << endl;
		MonSpeed + 10;
	}
	if (MonstersBase[3] == 6)
	{
		cout << " Its legs are decidedly average" << endl;
	}
	if (MonstersBase[3] == 7)
	{
		cout << " Its legs are darker than its body" << endl;
	}
	if (MonstersBase[3] == 8)
	{
		cout << " It has reinforced scales on its legs" << endl;
		MonMAXHP + 5;
		MonDef + 5;
	}
	if (MonstersBase[3] == 9)
	{
		cout << " Its legs are lighter than its body" << endl;
	}
}

void DescribeMonOrigin5()
{
	if (MonstersBase[4] == 0)
	{
		cout << " It gnashes and snarls at all who approach" << endl;
	}
	if (MonstersBase[4] == 1)
	{
		cout << " It seems to refer being alone" << endl;
	}
	if (MonstersBase[4] == 2)
	{
		cout << " It has hauntingly beautiful blue eyes" << endl;
	}
	if (MonstersBase[4] == 3)
	{
		cout << " It seems particularly untrustworthy" << endl;
	}
	if (MonstersBase[4] == 4)
	{
		cout << " It seems to prefer heat" << endl;
	}
	if (MonstersBase[4] == 5)
	{
		cout << " It seems to prefer the cold." << endl;
	}
	if (MonstersBase[4] == 6)
	{
		cout << " It seems to have no issues trusting you" << endl;
	}
	if (MonstersBase[4] == 7)
	{
		cout << " It whines when left in the dark" << endl;
	}
	if (MonstersBase[4] == 8)
	{
		cout << " It seems to prefer social company" << endl;
	}
	if (MonstersBase[4] == 9)
	{
		cout << " It is rather vain" << endl;
	}
}

					void FullOriginDescribe() // To check Mon Stats
{
	void DescribeMonOrigin1();
	cout << "with" << endl;
	void DescribeMonOrigin2();
	cout << " and " << endl;
	void DescribeMonOrigin3();
	cout << " Its legs?" << endl;
	void DescribeMonOrigin4();
	cout << " Finally, its temperment?" << endl;
	void DescribeMonOrigin5();
}
Well, two of my biggest complaints are that you have a lot of global variables that are not constant(You generally don't want to use global variables at all, but if you have too, make sure they're constant). My second complaint is that you're seeding more than once and you don't want to do that. You always want to seed only once. Of course, those complaints were only founded skimming through it very quickly. Meaning that there is probably more than what I found.
Cool, thanks for the pointers:)
Topic archived. No new replies allowed.