G
grocery_stocker
Here is a repeat of his code:
#include <stdio.h>
#include <ctype.h>
#define ROW 2
#define COL 5
static void init_array (char data[][COL], size_t row, size_t col)
{
size_t r;
for (r = 0; r < row; r++)
{
size_t c;
for (c = 0; c < col; c++)
{
data[r][c] = r + c;
}
}
}
static void print_array (char const data[][COL], size_t row, size_t
col)
{
size_t r;
for (r = 0; r < row; r++)
{
size_t c;
for (c = 0; c < col; c++)
{
printf ("%3d", data[r][c]);
}
printf ("\n");
}
}
int main (void)
{
char array[ROW][COL];
init_array (array, ROW, COL);
print_array (array, ROW, COL);
return 0;
}
Why don't you use prototypes?
#include <stdio.h>
#include <ctype.h>
#define ROW 2
#define COL 5
static void init_array (char data[][COL], size_t row, size_t col)
{
size_t r;
for (r = 0; r < row; r++)
{
size_t c;
for (c = 0; c < col; c++)
{
data[r][c] = r + c;
}
}
}
static void print_array (char const data[][COL], size_t row, size_t
col)
{
size_t r;
for (r = 0; r < row; r++)
{
size_t c;
for (c = 0; c < col; c++)
{
printf ("%3d", data[r][c]);
}
printf ("\n");
}
}
int main (void)
{
char array[ROW][COL];
init_array (array, ROW, COL);
print_array (array, ROW, COL);
return 0;
}
Why don't you use prototypes?