waifurchin
Technical User
New to C in general.
I have a multi-function array (data[10][10]) defined.
This array gets passed to a function (ex. Foo((*x)[10])). So far this works fine - I can access the elements in the array within the Foo function without a hitch.
Now, I need to add a new function call within Foo (ex. Foo2((*x)[10])) that also uses the same array, but I can't get this declaration to work.
In full (this is a bogus situation, but it illustrates what I'm looking for):
#include <stdlib.h>
#include <stdio.h>
int Foo((*x)[10])
{
printf("%d",x[1][1]); // Works
Foo2(x);
return 0;
}
void Foo2((*x)[10])
{
printf("%d",x[1][1]); // Doesn't work
return 0;
}
void main(void)
{
int data[10][10],i,ii; // New int array
for(i=0;i<10;i++)
for(ii=0;ii<10;ii++)
data[ii]=5; // Initialize all to 5
Foo(data);
return;
}
Why does the Foo2 parameter list not work?
I have a multi-function array (data[10][10]) defined.
This array gets passed to a function (ex. Foo((*x)[10])). So far this works fine - I can access the elements in the array within the Foo function without a hitch.
Now, I need to add a new function call within Foo (ex. Foo2((*x)[10])) that also uses the same array, but I can't get this declaration to work.
In full (this is a bogus situation, but it illustrates what I'm looking for):
#include <stdlib.h>
#include <stdio.h>
int Foo((*x)[10])
{
printf("%d",x[1][1]); // Works
Foo2(x);
return 0;
}
void Foo2((*x)[10])
{
printf("%d",x[1][1]); // Doesn't work
return 0;
}
void main(void)
{
int data[10][10],i,ii; // New int array
for(i=0;i<10;i++)
for(ii=0;ii<10;ii++)
data[ii]=5; // Initialize all to 5
Foo(data);
return;
}
Why does the Foo2 parameter list not work?