I want to copy arr2 to arr and pass arr as a function paramater
void func(char * array)
{}
int main(void)
{
int a;
char arr[6][50];
char arr2[][50]={"qweeeaa","bbbb","ffaa","eeaa","aaaa","ffaa"};
for(a=0; a<6;a++)
{
strcpy(arr[a], arr2[a]);
}
func(arr);
return 0;
}
But I can not pass arr as a function parameter. I get
[Warning] passing argument 1 of 'func' from incompatible pointer type [enabled by default]
[Note] expected 'char *' but argument is of type 'char (*)[50]'
I am using MinGW GCC 4.8.1
The type you pass and the type the function expects do not match. Change the function to receive a pointer to an array:
Other problems:
1) You haven't declared a prototype for
func()either. In pre-C99 mode, compiler would assume the function returns anintand this would cause problem. In C99 and C11, missing prototype makes your code invalid. So either declare the prototype at the top of the source file or move the function abovemain().2) Include appropriate headers (
<stdio.h>for printf etc).