Ive been trying this for hours no and have made no progress, the programme should create a 2D array in the function of a 16 by 16 grid of x's and then in the main programme i should be able to print this grid on the console but when run i get no result, any help would be apreciated (newbie)
#include <iostream>
#include <cstdlib>
char **create2DArray(); //function prototype
#define WIDTH 16
#define HEIGHT 16
char** myArray; //global array
char **create2DArray(){
int i,j;
char **array = (char **) malloc(sizeof(char *) * WIDTH);
for(i=0; i<WIDTH; i++)
array[i] = (char *) malloc(sizeof(char) * HEIGHT);
for(i=0; i<WIDTH; i++)
for(j=0; j<HEIGHT; j++)
array[i][j] = 'x';
return array;
}
int main(int argc, char** argv) {
char **create2DArray();
myArray = create2DArray();
void printArray(char** array);
return 0;
}
void printArray(char** array);What is this supposed to do? This does not call any function, if that is what you're trying to do. In addition, I do not see a function that prints.