Quote Originally Posted by Alexius Lim View Post
hey ronin... thanks u got me what i wanted... could u explain to me about the if part? how why the if(r == -1 || r == ROW || c == -1 || c == COLUMN)


Code:
for(c = -1; c  <= COLUMN; ++c)
        {
            if(r == -1 || r == ROW || c == -1 || c == COLUMN)
                putchar('*');
            else
                putchar(b[r][c]);
        }

Glad you were able to get what you needed. I approached it along the lines of

Code:
for(r = -1; r <= ROW; ++r)
{
    for(c = -1; c <= COLUMN; ++c)
    {
        if(r == -1 || r == ROW || c == -1 || c == COLUMN)
            putchar('*');
        else
            putchar(arr[r][c]);
    }

    putchar('\n');
}
array[15][15] is 15 characters wide by 15 characters high, so the border needed to be 17 characters wide by 17 characters high.

Code:
start   valid index     end
 -1  <->  [0-14]   <->  ROW
(1)   +    (15)     +   (1) = 17 characters
when r == -1 or r == ROW the if branch is taken for 17 iterations of c (-1 through COLUMN), which prints outs the top or bottom border. Once r is between 0 and ROW-1, the if path is taken only when c == -1 or c == COLUMN, printing a single '*' on either the left or right edge for 15 iterations of r (0 through ROW-1). Otherwise, r is between 0 and ROW-1 and c is between 0 and COLUMN-1, which becomes valid index positions for the array.
Code:
     -1  [0-14] COLUMN
 -1   **************
[ 0]  *   array    *
[14]  *            *
ROW   **************
Personally, I find it easier to embed the border in the array; it really doesn't matter though, it's just another way to reach an end.