variables and astrisks
I see it at times when I get build errors and I see it here as well.
The first two are commonly seen. The top is a normal variable. The one below it is a pointer, but the second one, though I'm not sure of the formatting, I see errors like this:
int example; // a normal variable
int *examplepointer; // a basic pointer
int **unknown; // what is this?
"cannot convert something to (**void)"
What does the ** represent, what is it for, and how is it used?
Well one would think, a pointer to a pointer :)
I gather you see the trend ? :P
int example; /* a normal variable */
int *examplepointer; /* a pointer */
int **unknown; /* pointer to a pointer */
int ***unknown_even_more; /* pointer to a pointer to a pointer :) */
example = 5;
*examplepointer = example;
unknown = &examplepointer;
unknown_even_more = &unknown;
printf("example = %d, examplepointer = %d, unknown = %d, unknown_even_more = %d", example, *examplepointer, **unknown, ***unknown_even_more);
A pointer to a pointer? Strange. What sort of case would that be used for? I understand the use of pointers to a variable, but a pointer to a pointer doesn't seem to have any use as it seems rather bizarre. That could be why it's quite rarely seen. The tutorial on this site didn't cover or mention this as I just checked barely 20 minutes ago.
You can also have a pointer to a pointer to a pointer to a pointer... I don't know how many you can have but meh...
It can be used for example when allocating 2d arrays on the heap, or 3d (pointer to a pointer to a pointer), 4d etc..
> A pointer to a pointer? Strange. What sort of case would that be used for?
Like argv of main perhaps - that is such an animal.