Hi guys, I'm having some trouble printing out a 4x4 grid. A 1x1 grid is supposed to look like this:
Code:
+----+
| |
| |
| |
+----+
I've come close but I'm not quite there yet.
Code:
int main() {
row_count = 2;
col_count = 2;
strcpy(row0NoX, "-----+");
strcpy(row1NoX, " |");
strcpy(row2NoX, " |");
strcpy(row3NoX, " |");
strcpy(row4NoX, "-----+");
for (row = 0; row < row_count; row++) {
for (tiny_row = 1; tiny_row < N_ROWS; tiny_row++) {
printf("%c", row0NoX[strlen(row0NoX)-1]);
printf("%c", row1NoX[strlen(row1NoX)-1]);
printf("%c", row2NoX[strlen(row2NoX)-1]);
printf("%c", row3NoX[strlen(row3NoX)-1]);
printf("%c", row4NoX[strlen(row4NoX)-1]);
for (col = 0; col < col_count; col++) {
switch (board[row][col]) {
case 0:
switch (tiny_row) {
case 1:
printf("%s", row0NoX);
break;
case 2:
printf("%s", row1NoX);
break;
case 3:
printf("%s", row2NoX);
break;
case 4:
printf("%s", row3NoX);
break;
case 5:
printf("%s", row4NoX);
break;
default:
printf("Error");
break;
}
break;
}
}
printf("\n");
}
}
return (0);
}
What I'm getting if I set the grid to 2x2 is this:
Code:
+|||+-----+-----+
+|||+ | |
+|||+ | |
+|||+ | |
+|||+-----+-----+
+|||+-----+-----+
+|||+ | |
+|||+ | |
+|||+ | |
+|||+-----+-----+
The problem with this is its not printing the | at the beginning of the grid but +s. Plus, it's also printing out a space between the two grids which might be because of the \n I put in there...