For example, which term completes the sentence "p
has 5 ____" in order to describe a situation like int *****p
?

- 79
- 2
-
6"Levels of indirection". (See https://en.wikipedia.org/wiki/Fundamental_theorem_of_software_engineering) – Kilian Foth Sep 18 '22 at 10:11
-
Why do you need a specific term? If, for example, in some documentation, you write "p can be dereferenced 5 times" or "p can be dereferenced over 5 levels" does not make a huge difference in length or clarity". – Doc Brown Sep 18 '22 at 18:49
1 Answers
Levels.
A pointer is used to point to a memory location of a variable. A pointer stores the address of a variable and the value of a variable can be accessed using dereferencing of the pointer. A pointer is generally initialized as:
datatype *variable name;
This above declaration is a single pointer but there can be more than this. This is called levels of pointers. According to ANSI C, each compiler must have at least 12 levels of pointers. This means we can use 12 * symbols with a variable name.
Level Of Pointers in C/C++:
Level of pointers or say chain can go up to N level depending upon the memory size. If you want to create a pointer of level-5, you need to precede the pointer variable name by 5 asterisks(*) at the time of declaration.
How many levels of pointers can we have in C/C++ - geeksforgeeks.org
See also
- C++ Pointers: Number of levels of Indirection, and
- ANSI C allows for up to 12 levels of pointers. Why would you ever use more than 3 or 4 levels?
Just to be clear, this 12 thing they keep going on about is just counting how many *'s you can use in one go. But you can stick it in a loop and dereference as many times as you like. Well, so long as the value you find there never sends you outside of addressable memory.

- 102,279
- 24
- 197
- 315
-
Well 'level' alone is a shortcut and is not sufficient, and geeksforgeeks is not really autoritative. 'Level of indirection' would be more accurate and less ambiguous imho. – Christophe Sep 18 '22 at 09:16
-
@Christophe adding “indirection” is as redundant as adding “dereference”. Also, I’m showing usage. I don’t recognize anyone as having authority here. It’s called what it’s called. That’s how language works. – candied_orange Sep 18 '22 at 12:24
-
1The term "level" isn't wrong, but to use it for the OPs case, one would still have to write "we can dereference this pointer over 5 levels". And for this, I don't see any benefits in comparison to "we can dereference this pointer 5 times". Saying "this pointer has 5 levels", however, is probably not clearly telling anyone what was meant. – Doc Brown Sep 18 '22 at 18:53