Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi-Dimension Array Passthrough

Status
Not open for further replies.

waifurchin

Technical User
Mar 3, 2003
1
US
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?
 
Try prototyping foo2() before actually trying to call it from foo1()

#includes

void foo1( int (*x)[10] );
void foo2( int (*x)[10] );

rest of code


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top