May 19, 2012 at 12:16pm
Line 8 in your code, x<26
?
May 19, 2012 at 12:29pm
I see a typo
1 2
|
for(x=0;x<26;x++)
grid[x][15] = '.';
|
you array has only
16 rows not
26.
To escape such a typo it is better to set dimensions of an array with constants.
For example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
const size_t N = 16;
char grid[N][N];
for ( size_t i = 0; i < N; i++ )
{
for ( size_t j = 0; j < N; j++ )
{
if ( i == 0 || j == 0 || i == N - 1 || j == N - 1 ) grid[i][j] = '.';
else grid[i][j] = ' ';
}
}
for( size_t i = 0; i < N; i++ )
{
for ( size_t j = 0; j < N; j++ )
{
cout << grid[i][j];
}
cout << endl;
}
|
I have not tested this code but hope it is correct.
Last edited on May 19, 2012 at 12:54pm