I'm trying to learn pointers in c and have been trying to write samples of code for different types of situations that involve pointers that I have found in this C book
in "Examples of pointer constructs" but I can't seem to figure out how to return a pointer to a pointer to a pointer to an int from a function or how to dereference such a pointer in main.
I have been searching for a simple example all over but couldn't find one to make it clear for me. Could anyone explain this concept and how such pointers work inside functions?
I've had no problems returning a pointer to int from a function and understood the process but higher levels gave me a hard time. I've been trying to write very basic examples but I can't manage to store what this function returns in main, and also how I should dereference it:
int ***func(int x) {
int n = x * x;
int *p1, **p2, ***p3;
p1 = &n;
p2 = &p1;
p3 = &p2;
return &p3;
}
*and**and forget the higher levels of indirection