I'm pretty new to programming, so there is probably some obvious mistake that I am missing, but here goes. I am trying to create random rooms on the screen that a character can explore in a very simple dungeon-esque game. However, when I assign a value to a certain point on the matrix, it assigns that value to the entire column. Here is the code:

Code:getmaxyx(stdscr, row, col); int room1[row][col]; for(d = 0; d <= row; d++) { for(e = 0; e <= col; e++) { room1[d][e] = 0; } } for(f = 1; f <= 10; f++) { srand(time(NULL)*seed1); g = rand() % (row); seed2 = rand()/(RAND_MAX * 1.0); srand(time(NULL)*seed2); h = rand() % (20); h = g + h; seed3 = rand()/(RAND_MAX * 1.0); srand(time(NULL)*seed3); i = rand() % (col); seed4 = rand()/(RAND_MAX * 1.0); srand(time(NULL)*seed4); j = rand() % (20); j = i + j; seed1 = rand()/(RAND_MAX * 1.0); mvprintw(0,0,"(%d, %d)",g,h); getch(); for(o = g; o <= h; o++) { for(p = i; p <= j; p ++) { room1[o][p] = 1; /* Here is the problem */ } } } for(m = 0; m <= row; m++) { for(n = 0; n <= col; n++) { if(room1[m][n] == 1) { mvprintw(m,n, "1"); } } }