I'm currently developing a simple naval battle game for my first exam at my college but i'm getting a strange output on my gameboard...
It should be iterating my "j" variable, but instead I get that strange character...
Here's my code:
//CREATES COORDENATES OF THE GAMEBOARD
//ATTRIBUTE ONE LETTER TO EACH TRAY LINE
for (i=0;i<11;i++){
tabuleiro[i][0] = letra[i-1];
}
//ATTRIBUTE ONE NUMBER TO EACH TRAY COLUMN
for (j=1;j<11;j++){
tabuleiro[0][j] = j;
}
//CREATES THE "SEA"
for (i=1;i<11;i++){
for (j=1;j<11;j++){
tabuleiro[i][j] = '~';
}
}
I've tryied to change my tabuleiro[0][j] = j; to tabuleiro[0][j] = (j+'0'); but then it only iterates until 9 and give me strange characters again...
If I'm not wrong I think this has something to do with the ASCII code (please correct me if I'm wrong) but I've no clue how to fix this.
Could you explain me how can I solve this please.


:the "strange" character you're mentioning? What do you expect instead of the "strange character" ?tabuleiro[i][0] = letra[i-1];wheni == 0, you'll get a negative index. Probably not what you want.