void printTable(char (*tacToe)[3], int row, int col){

}

void initTable(char (*tacToe)[3], int row, int col){

}

int main(void){
    char tacToe[3][3];
    initTable(tacToe, 3, 3);
    printTable(tacToe, 3, 3);
}

here is my question. what is the difference between *ary[] and (*ary)[]?
when i did the program initially like so:

void printTable(char *tacToe[3], int row, int col){

}

void initTable(char *tacToe[3], int row, int col){

}

int main(void){
    char tacToe[3][3];
    initTable(tacToe, 3, 3);
    printTable(tacToe, 3, 3);
}

it does not work. now, from my understanding, but mainly just some guessing, is that (*ary)[] is declaring an array of pointers, while *ary[] is declaring a pointer to an array? when i thought about it, it should be pretty much, if not completely the same.

is it not that the name of the pointer array points to the first pointer in the array while the pointer to an array is well pretty much the same since an array is a pointer as well.

It doesnt make sense. Why would (*ary)[] be a pointer to an array? Should not the parenthesis first define the pointer inside and the brackets declare that it is an array which just so happen to be a pointer?

also, my code should not work if (*ary)[] is merely a pointer to an array since I was trying to pass a two dimentional array rather than a single dimention array.

Why not define your function like below?

void printTable(char tacToe[][3], int row, int col)
{

}

void initTable(char tacToe[][3], int row, int col)
{

}

int main(void)
{
    char tacToe[3][3];
    initTable(tacToe, 3, 3);
    printTable(tacToe, 3, 3);
	
	return 0;
}

It would be too easy if i just did that. Also, I was trying to make the function as reusable as possible. Like I would not have to modify the parameters if I had to use it again but with a different sized array. So yeah, what I need is an explanation really. That link you gave me pretty much messed my whole theory up. lol

Also, thank you for your time. I really appreciate your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.