When I want to pass a "char (*c)[10];" as a parameter,
what argument should I define in my function definition?
I mean, if I have a function:
void foo(*****) { ... }
I want to pass char (*c)[10]; to it, so what do I write in place of *****?
When I want to pass a "char (*c)[10];" as a parameter,
what argument should I define in my function definition?
I mean, if I have a function:
void foo(*****) { ... }
I want to pass char (*c)[10]; to it, so what do I write in place of *****?
You should be able to pass it simply as you're declaring it:
void foo(char (*c)[10]);
And call it as:
foo(c);
This is the best post on this subject: C pointers : pointing to an array of fixed size
Define the function as:
void foo(char (*c)[10])
{
for (int i = 0; i < sizeof(*c); i++)
printf("%d: %c\n", i, (*c)[i]);
}
Use the function as:
int main(void)
{
char a[10] = "abcdefghi";
char (*c)[10] = &a;
foo(c);
return(0);
}