A few things, first of all if you are going to do this,
void print_array(char *arr,int8_t cnt);
void print_array(char *arr,int8_t cnt) {}
It is better to just do the later one, remove the declaration statement and keep the definition (and declaration) on only. Secondly, since you already know how to pass strings (which are array of characters). Like this,
print_array(char *arr, int8_t cnt) { }
What stops you from doing this?
print_arrays(char **arr, int8_t cnt) { }
Notice that I used a
pointer to pointer[
^] here. Which means, or at least I can say, in the C language context, an array of array. You can do the following on it, then,
char **array = { "Afzaal", "Ahmad", "Zeeshan" };
Finally, I didn't actually get the part where you wanted to
assign the pointer to the array, because you actually
get the pointer to the array. However, that would now take us in the realm of C++ where references are supported and as far as I can conclude, C doesn't support pass-by-reference, only pass-by-value and that is exactly why the C functions look like this,
void func(char *obj) {
}
int main() {
int a = 25;
func(&a);
}
I would move you onwards to learn something, keep trying. My personal recommendation is to use GCC compiler. That is a good one and I personally like it.
Passing value by reference in C and C++ - C++ Forum[
^]
Strings in C[
^]
C Strings - Cprogramming.com[
^]