I want to format a grid nicely. It is 9x9 grid. I want to delimit it
after every 3rd column - put "*"
else - '\t'.
after every 3rd row put "-------------------------"
Horizontal line works nicely - this is easy.
But in column 3 it starts printing only 2-3 spaces instead of '\t'.
The code:
static int grid[9][9] ;
void print_grid(){
cout << "PRINTING GRID" <<endl ;
for(int row = 0 ; row < 9 ; row++){
for(int column = 0 ; column < 9 ; column++){
if(column > 0 && (column + 1) % 3 == 0 && (column + 1) != 9 )
cout <<grid[row][column] << " * " ;
else cout <<grid[row][column] <<"\t" ;
}
if( (row+1) % 3 == 0){cout <<endl ;
cout << "---------------------------------------------------------------------" <<endl ;}
else cout <<endl <<endl ;
}
}
int main(){
print_grid() ;
return 0 ;
}
My question is: in the red area why does it print 2-3 spaces instead of "\t" ? why does '\t' change its length??