More on Multi-dimensional arrays. Question on Mr. Emmanuel Delahaye code

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?
 
P

Peter Nilsson

grocery_stocker said:
Here is a repeat of his code:

Which I've snipped, but preserved the code order...
...
static void init_array (char data[][COL], size_t row, size_t col)
...
static void print_array (char const data[][COL], size_t row, size_t
...
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?

He has used prototypes. A prototype is a 'full' function signature,
not a pre-declaration of a function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top