Hello, i know that * is a pointer, also i know for ** is a pointer to a pointer...

i can understand that

int *x;
int y;
x=&y;

but last days i see something like this, and is a little hard to me to understand it.

void **getxyz()
{
   int **x;
     ;;...bla bla...
}

why to make a point to point?, and what about usage? where we use it? i need a simple explanation.

*YG: my question have to do more with functions, first time i saw a function-pointer , i know only for variables pointers...

It would also mean a 2 dimensional array. But I'd have to know what "...bla bla ..." says

Member Avatar for MonsieurPointer

It could also mean something like this:

int *pArray = NULL;

void fillArray(int **ppArray)
{
     int index;

     (*ppArray) = (int *)malloc(3 * sizeof(int));

     for (index = 0; index < 3; index++)
     {
          (*ppArray)[index] = index;
     }
}

fillArray(&pArray);

free(pArray);

pArray = NULL;

The function fillArray not only allocates memory for pArray (3 ints), but also fills it.

void **getxyz()
{
   int **x;

This is a red flag, by the way. While void* is C's generic pointer type which can be implicitly converted to any other pointer type[*], void** doesn't have the same properties. If getxyz() above tries to return x , the compiler will complain about an incompatible pointer type.


[*] Except a function pointer.

Monsieur, that exactly but alose i see functions-pointers

void **fname(FILE *f)
{
   // code...
}

Ancient, my question was simple, and bla bla means //code... it can be whatever, i guesse your IQ need some work ...

commented: Rude. -4
commented: Curious and brave. Demonstrates a strong will and persistence in pursuit of the truth. Also, has a thick skin. +5

Monsieur, that exactly but alose i see functions-pointers

It's not a pointer to a function, it's a function that returns a pointer.

Ancient, my question was simple, and bla bla means //code... it can be whatever, i guesse your IQ need some work ...

AD's question was legitimate and your response is uncalled for. It's impossible to say for sure how the pointer is being used when you replace its usage with "bla bla". One can only speculate and make an educated guess.

It's not a pointer to a function, it's a function that returns a pointer.


AD's question was legitimate and your response is uncalled for. It's impossible to say for sure how the pointer is being used when you replace its usage with "bla bla". One can only speculate and make an educated guess.

yea ok but my main question was about **functions and not variables
anyway :)

Then your question makes no sense. Please rephrase it.

Then your question makes no sense. Please rephrase it.

No need, i took answer

"Pointer Function's return a pointer"

:)

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.