Edit: Thanks for all the answers.
Hi,
How do I pass 2D array to a function correctly?
Here's my code which doesn't work.
Code:
#include <stdlib.h>
#include <stdio.h>
#define MAX_ROW 2
#define MAX_COLUMN 2
void display_seats(char **);
int main(void)
{
char seats[MAX_ROW][MAX_COLUMN] = { 0 };
// int input_row, input_column;
int i, j;
/* Init the row and columns */
for(i = 0; i < MAX_ROW; i++)
{
for(j = 0; j < MAX_COLUMN; j++)
{
seats[i][j] = 'X';
}
}
display_seats(seats);
return EXIT_SUCCESS;
}
void display_seats(char **seats)
{
int i, j;
for(i = 0; i < MAX_ROW; i++)
{
for(j = 0; j < MAX_COLUMN; j++)
{
printf("%c", seats[i][j]);
}
printf("\n");
}
}
MSVC++ 6 gives me two warnings,
warning C4047: 'function' : 'char ** ' differs in levels of indirection from 'char [2][2]'
warning C4024: 'display_seats' : different types for formal and actual parameter 1
Thanks.