convert 2d character array to 2d integer array

simply what i want to know is if i can take a 2d array of characters and convert them to a 2d array of integers.

My wanting to do this is to add a tile map to the project. i know how to do it just not with characters. only using integers.

please see this:
http://www.cplusplus.com/forum/general/74820/

1
2
3
4
5
6
7
8
9
10
11
12

char Level[25][25] =
    {
         "#####",
         "#...#",
         "#...#",
         "#-.+#",
         "#####"
    };
    
char IntegerLevel[25][25] = static_cast<char>(Level[25][25]);
That isn't a 25x25 array, that's a 5x5 array.
You'd have to use a 2x for-loop and cast each element over one at a time.
1
2
3
for (int i = 0; i < 5; i++)
    for (int j = 0; i < 5; j++)
        casted_array[i][j] = other_array[i][j];
Last edited on
Topic archived. No new replies allowed.