passing a pointer to an array to the function

Hi everyone, I don't know if the title is right or no, because I don't really care about the terms in programming.

please see this code below :

#include <stdio.h>
int a=1;
int b=2;
int c[1];
int main()
{
    test(a, b, &c);
    printf("%d", c[0]);
    return 0;
}
void test(int A, int B, int *C[1])
{
  *C[0] = A + B;
}

it worked if I remove the array (only using integers). but it wont work if i use the Array. is there any way to make it work? I need to use this kind of code in my project. Sorry for my bad english and not using c arduino. I just want to test it.

many thanks :slight_smile:

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

You are very likely stumbling over operator precedence (the array dereference is higher priority).

But, you are also grossly over-complicating the situation.

Try this...

#include <stdio.h>
int a=1;
int b=2;
int c[1];
int main()
{
    test(a, b, c);
    printf("%d", c[0]);
    return 0;
}
void test(int A, int B, int C[1])
{
  C[0] = A + B;
}