The problem with representing Data Structures Using C that are not linear. We need some way to map these data structures to the computer's linear memory. One solution to this, is to use pointers.
A D V E R T I S E M E N T
Pointers are the memory locations that are stored in the memory cells. By using a pointer, by holding a memory address rather than the data one memory cell can point to another memory cell.
The memory cell at address 2003 contains a pointer the address of another cell, which can be seen in the above figure. Here the pointer is pointing to the memory cell 2005 which contains the letter C. This means that, we have two ways of accessing the letter C. We can refer to the memory cell which contains the value C directly or we can use the pointer to refer to it indirectly. The process of accessing the data through pointers is known as indirection. Using pointers, we can also create multiple levels of indirection.
Pointers can become very complex and difficult to use by having many levels of indirection. When used pointers incorrectly, it can make data structures very difficult to understand. The tradeoff between complexity and flexibility should be consider whenever you use pointers in constructing data structures.
The idea of pointers and indirection is not exclusive to the computer memory. Pointers appear in many different aspects of computer's usage. Hyperlinks in web pages is a good example pointers. This links are really the pointers to the other web page. Perhaps you have even experienced the double indirection when you went to visit the familiar web site and found the site had moved. You saw a notice that the web pages had been moved and a link to the new site, instead of the page you expected.
|