function to initialize 2D array

I am completely confused about this problem. When I post the code in the main function, the initialization of the array works. When I put the code into a function I get the following error:

cannot convert `status (*)[6]' to `status*' for argument `1' to `void initializeArray(status*, int, int)'

The source code is posted below.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cctype>
#include <cstddef>

using namespace std;

// global constants
const int MAX_ROWS = 15,
MAX_SEATS = 6;

// global data type definitions
enum status { EMPTY, RESERVED, PURCHASED };

// function prototypes
void initializeArray( status[], int, int );

int main()
{
// variable declarations
status seatStatus[ MAX_ROWS ][ MAX_SEATS ];

initializeArray( seatStatus, MAX_SEATS, MAX_ROWS );

cout << endl << endl;
system("PAUSE");
return 0;
}

void initializeArray( status seatStatus[][ MAX_SEATS ], int rows, int seats )
{
for ( int row = 0; row < rows-1; row++ )
for ( int seat = 0; seat < seats-1; seat++ )
seatStatus[row][seat] = EMPTY;
}
You declaration for initializeArray() doesn't match your definition.

Try using pointer notation rather than array notation for the status argument.
Last edited on
Topic archived. No new replies allowed.