# Thread: prototype of a function taking a pointer to interger array as a parameter

1. ## prototype of a function taking a pointer to interger array as a parameter

the error massage read as : " )" expected in the line of the prototype.
and declararion terminated incorrectly.
i 'm wondering where are the mistakes. thanks for help.
the code is

Code:
```int total (int [] (*));
int main()

{int j,i;
int [] (* ptr)[8]={
{6,6,6,6,6,6,6,6} ,
{ 6,2,2,2,2,2,2,6,  } ,
{6,3,1,0,1,1,2,7,   }  ,
{ 6,6,5,0,1,5,6,6,  }   ,
{6,6,5,3,3,5,6,7,  }    ,
{ 7,6,5,3,2,6,6,7,  }   ,
{ 7,6,6,2,2,5,6,7, }    ,
{ 7,7,7,7,7,7,7,7,}    ,

};
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{

if(*(ptr[i]+j)<total(ptr[i]))
printf("%c",219) ;
else
printf(" ");

printf("\n")
}   ;
} ;

return 0;
}
int total(int [](*p))
{ int sum=0,i;
for(i=0;i<8;i++)
sum+=*(p+i);

return (sum/8);
}```

2. What are you trying to do with this?
Code:
`int [] (* ptr)[8]`

besides this there are a lot of syntax errors in your program.
[/edit]

3. hahan,

In total, you are trying to pass in a pointer to the start of an array. You can use
int total(int* p) if you want to access the array as you have done in your version with sum+=*(p+i), or you can declare total with int total(int p[]) and use sum += p[i]

I think with int [] (* ptr)[8] you are trying to declare an array of pointers to arrays of 8 elements. Maybe there's a way to do that, but I'm used to simpler syntax. Try

Code:
```int ptr[][8] =
{
{6,6,6,6,6,6,6,6} ,
...
};```
This means you have an array of subarrays. Each subarray is 8 elements long, as specified by the 8. The first dimension does not need to be specified because the compiler will count up the number of subarrays you are specifying. If you did not have the initialization of ptr, then the first dimension would have to be specified.

and call total(ptr[i]) in your loop as you are doing now.
Then work on cleaning up the rest of your syntax errors.