Having trouble with my code here, cant get the numbers to appear at all, much less in a 2d array, outputs 9 "_" chars separated by new line every time. I apologize for my lack of understanding of how this forum works ahead of time, but I'm stumped and could use any help I can get.

[code hidden away - please don't post so much code publicly]


Two serious problems. First, you have declared board[d][d] inside of the init() function. This means that you're creating what's called a shadow of the global array board. The shadow takes precedence locally inside the function. That means that you're populating the shadow array, not the global array. The shadow array ceases to exist when the init() function is exited, leaving the global array with all zeros.

Next, you're printing each array element, or tile, on a separate line because of where you placed the printf("\n"); statement. Since it is inside the inner for loop, it will execute with each tile printed. It needs to be placed... ooh, I almost gave it away..... somewhere else so that it only executes at the end of each row. ;-)

There may be other issues, but this will get you going.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .