#include <stdio.h>
int main() {
char map [3][6] = {
{'a','.','.','.','.','.'},
{'.','.','.','.','.','.'},
{'.','.','.','.','.','.'}
};//Create a new game map
char* newmap = map;
printf("%c",newmap); //Print first element
return 0;
}
The code I have does not work. I am trying to make a pointer to map[3][6] and then be able to print the array from the pointer.
'\0'required to treat an array as a character string. Your pointer must bechar (*newmap)[6] = map;to use as you have shown on a character basis. Useputchar (*newmap);to output a single character.char **ptr = & newmap;is very very wrong. Where willptrpoint after you doptr++? -- hint: it will depend onsizeof (a_pointer)on the architecture you are using -- not what you want)