i've been at this for an hour, feeling stupid by now, getting sick of these segmentation faults..
// board.cpp
#include <iostream>
using namespace::std;
const int NUM_ROWS = 10, // Board dimensions
NUM_COLS = 20;
// Function prototypes
void fillRectangle ( char board[NUM_ROWS] [NUM_COLS] ,
int row, int col,
int width, int height, char fillChar );
void displayBoard ( const char board[NUM_ROWS] [NUM_COLS] );
//--------------------------------------------------------------------
int main ()
{
char board[NUM_ROWS][NUM_COLS]; // Message board
// Initialize the message board to all periods.
fillRectangle(board,0,0,NUM_COLS,NUM_ROWS,'.');
// Load and display a message.
fillRectangle(board,2,2,6,2,'C');
fillRectangle(board,4,2,3,4,'C');
fillRectangle(board,6,5,3,2,'C');
fillRectangle(board,4,10,3,1,'#');
fillRectangle(board,3,16,1,3,'#');
fillRectangle(board,3,11,1,3,'#');
fillRectangle(board,4,15,3,1,'#');
cout << endl;
displayBoard(board);
return 0;
}
//--------------------------------------------------------------------
// Insert your function implementations here.
//--------------------------------------------------------------------
void fillRectangle ( char board[NUM_ROWS][NUM_COLS],
int row, int col,
int width, int height, char fillChar )
// Fills in the specified rectangle on the message board with the
// character fillChar.
{
for(int i = row; i < width + row; i++)
for(int j = col; j < height + col; j++)
board[i][j] = fillChar;
}
//--------------------------------------------------------------------
void displayBoard ( const char board[NUM_ROWS][NUM_COLS])
// Displays the message board.
{
for(int i = 0; i < NUM_ROWS; i++)
for(int j = 0; j < NUM_COLS; j++)
cout << board[i][j];
}
/*
....................
....................
..CCCCCC............
..CCCCCC...#....#...
..CCC.....###..###..
..CCC......#....#...
..CCCCCC............
..CCCCCC............
....................
....................*/