Hi Serge,
There are a few issues with your code... I'll go through some examples here
Code:
#include <stdio.h>
#include <stdlib.h>
#define PERSONS_NUM 4
char Names[PERSONS_NUM][40] = {
"Hanna",
"Jim",
"Gregory",
"Will"
};
/* when passing in a 2d array you need to use the following
syntax. It's all memory....*/
void PrintString(char c[][40])
{
/* your loop is a mess. Use the following */
int counter;
counter = 0;
while(counter < PERSONS_NUM)
{
/* putchar is the wrong function to use..I suggest
puts() */
puts(c[counter]);
counter++;
}
}
int main(void)
{
/* you only need to pass in the name of the array.
The name of the array is a pointer to the first
element of the array */
PrintString(Names);
return EXIT_SUCCESS;
}
I've compiled and run the above code using clang on MacOS. It should also work with other compilers
Remember, that it's all memory. An array name is a pointer to the first element of the array!
I hope this helps.