You must be just another victim of the people that start with java and then trying to get into c, that's why I will answer.
I want to initialize my array inside of that parameter. How can that be done?
You cannot. prior to C99
In general, this is something you could do:
#include
void foo(char** arr, int size)
{
int i;
for(i = 0; i < size; ++i)
printf("%s\n", arr[i]);
}
void bar(char** arr)
{
while(*arr)
printf("%s\n", *arr++);
}
int main(void)
{
char* x[] = { "hello", "my", "friend" };
foo(x, 3);
char* null_terminated[] = { "ShadowRanger", "Correct", NULL };
bar(null_terminated);
return 0;
}
where foo()
uses the size of the array explicitly, while bar()
requires the array to be NULL terminated.