Turning a # symbol into an ascii symbol

Im programming a roguelike game using visual c++ Microsoft express 2010 and i made a multidimensional array for my first map. I have the walls as # and was wondering how i could turn those into ascii symbol 219. Also i need to know how to turn specific text certain colors.
1
2
char c = '#';
int ascii = (int) c;


Casting Should Work For You. I Basically Changed The Char To An Int. As For Colors, Look At The Articles Section, I Believe There Is Something About That There.

note: Make Sure Your Terminal Is Configured To Support ASCII, Else You May Get An Unwanted Code.
Last edited on
Thx dude

I think OP means how can he display the character for character code 219.

cout << (char)219;

in action:

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
#include <iostream>

unsigned char map[10][10] = {

	1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
	0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
	0, 0, 0, 1, 0, 0, 1, 0, 0, 0,
	0, 0, 0, 0, 1, 1, 0, 0, 0, 0,
	0, 0, 0, 0, 1, 1, 0, 0, 0, 0,
	0, 0, 0, 1, 0, 0, 1, 0, 0, 0,
	0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
	0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
	1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
};


int main()
{

	for (int down = 0; down < 10; down++) {
		for (int across = 0; across < 10; across++)
		{
			switch (map[down][across])
			{
			case 0:
				std::cout << " ";
				break;
			case 1:
				std::cout << (char)219;
				break;
			}
		}
		std::cout << std::endl;
	}

	return 0;
}
█        █
 █      █
  █    █
   █  █
    ██
    ██
   █  █
  █    █
 █      █
█        █


When it finds 1 in the map data it will show character 219, otherwise a space will be drawn.

For colours, this post will help you.

http://www.cplusplus.com/forum/beginner/5830/

Topic archived. No new replies allowed.