Enums

Hello guys,
This is my first time when it comes to dealing with Enums so yea my codes might abit too dumb :S
so, I have 2 enums of the follow type

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  enum Region
{
A,
B,
C,
D,
};
enum Type{
	paver,
	shielded_fighter,
	fighter,
	tank,
};

and a struct of enemy
1
2
3
4
5
6
7
8
9
struct enemy
{
	int ID;		//Each enemy has a unique ID (sequence number)
	int time_step; //The time step of each enemey
	Region region;	//Region of this enemy
	int Health;	//Enemy health
	Type type;	//Paver,Fighter,SHielded fighter
	int reload_power;
	int fire_power;};

I have a file-loading function that reads a list of enemies and ignores the last one and places all these enemies in a queue(made by a linked list)

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
void loadData(castle &al3a, queue &q, float &c1, float &c2, float &c3)
{
	int i = 0;
	ifstream myfile;
	int n = 0;
	myfile.open("data.txt");
	if (myfile.fail())
	{
		cout << "Error" << endl;
		myfile.close();
	}
	else {
		string line;
		while (!myfile.eof())
		{
			n++;
			getline(myfile, line);
		}
	}
	myfile.close();
	string line2;
	int T_Health;
	int T_Attack_N_Enemies;
	int T_Fire_Power;

	myfile.open("data.txt");
	myfile >> T_Health >> T_Attack_N_Enemies >> T_Fire_Power;
	getline(myfile, line2);
	myfile >> c1 >> c2 >> c3;
	getline(myfile, line2);
	int a,b,c,d,e,f;
	char g;
	enemy x;
	for (int i = 0; i < n - 3; i++)
	{
		myfile >> a >> b >> c >> d >> e >> f >> g;
		x.ID = a;
		x.type = static_cast<Type>(b);
		x.time_step = c;
		x.Health = d;
		x.fire_power = e;
		x.reload_power = f;
		x.region = static_cast<Region>(g);
		enqueue(q, x);
		getline(myfile, line2);
	}
	for (int i = 0; i < 4; i++)
	{
		al3a.towers[i].Health = T_Health;
		al3a.towers[i].attackEnemies = T_Attack_N_Enemies;
		al3a.towers[i].firePower = T_Fire_Power;
		al3a.towers[i].Tregion = (Region)i;
	}
	
}


The problem is when I print this queue
i get the region section equal to 65,66,67 or 68

P.S
The text file looks something like this
1
2
3
4
5
6
7
200 3 14
1 0.03 0.01
1 0 1 25 2 4 A
2 2 3 20 5 4 A
3 1 7 11 2 3 B
4 2 9 30 2 4 D
-1


How can i get to print the regions as A,B,C,D not in ASCII code
thanks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

int main() {

	enum Region {
		A = 0,
		B,
		C,
		D,
		TypeSize
	};

	char RegionCharacter[Region::TypeSize] = {
		'A',
		'B',
		'C',
		'D'
	};

	Region region = Region::C;
	std::cout << RegionCharacter[region] << std::endl;

	return 0;
}
Topic archived. No new replies allowed.