understadning c notation

Hi,

I was wondering if somebody could tell me what int (*k)(int) notation means in c?

Thanks

I was wondering if somebody could tell me what
Code: [Select]

int (*k)(int)

notation means in c?

In what context?

That looks like a function prototype declaration that declares that there is a function that takes an int and returns an int, and that something is to take a pointer to that function.

As far as I know, k is a pointer to a function that takes and integer as argument and returns an integer.

The below gives a (quite useless in this case) example how it can be used.

int (*k)(int);

int myFunc1(int i)
{
  return i * i;
}

int myFunc2(int i)
{
  return i + i;
}

void setup()
{
  Serial.begin(9600);

  k = myFunc1;
  Serial.print("k=myFunc1; result of k(3): "); Serial.println(k(3));

  k = myFunc2;
  Serial.print("k=myFunc2; result of k(3): "); Serial.println(k(3));

}

The strength is that you can use one function call ( k(3) ) to achieve different results.