I am new to C programming and recently covered pointers. I wrote some code which made me confused. I tried to make up a possible explanation but it didnt seem correct.
Here is my code:
#include <stdio.h>
int main() {
int x = 5;
int* p = &x;
int*** q = &p;
printf("%u\n", *p);
printf("%u\n", *q);
printf("%u", ***q);
return 0;
}
What I have done is that I have declared a pointer p to x and then a pointer q to pointer p itself. The video that I was watching, there was firstly a **q pointing to p and when I tried to dereference it, I got the value which I was able to understand why and how it was doing that.
Now, I thought to change **q to ***q and when I tried to dereference it, it printed:
5
// the address
// and then a new line
Can you tell me why this happened? And what is meant by adding more stars to a pointer?