You can think of your grid array as a contiguous piece of memory. I would do:
bzero(grid, sizeof(int) * COLS);
bzero(grid + COLS * (ROWS - 1), sizeof(int) * COLS);
for (int i=1; i < ROWS-1; i++) {
*(grid + (i * COLS)) = 0; /* set left col to 0 */
*(grid + (i * COLS) + COLS - 1) = 0; /* set right col to 0 */
}
I used Sparrow in the past (https://en.wikipedia.org/wiki/Sparrow_(email_client)) for a few months until they were acquired by Google. Now some of the features they had were implemented in Gmail and Google Inbox.