review_pointers - Review of pointers in functions A pointer...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Review of pointers in functions A pointer is a data item whose value is the address in the memory of some other value. Pointers allow us to refer to a large data structure in a compact way. No matter how large the data structure grows, it will reside somewhere in the computer’s memory and therefore would have an address. We can use the address as a short hand for the complete value. All we need to store is an integer, irrespective of the size of the structure. So we may talk about a complete list with 5 nodes or 100 nodes with just one address. Pointers facilitate sharing data between different parts of the program. When we pass the address of some data value from one function to another, both functions have access to the same data. Pointers make it possible to reserve new memory during program execution (Dynamic allocation). We have already seen that pointers can also be used to record relationship among data items (such as nodes in a linked list). Suppose we want to point to an address where we have kept 45. *p=45;
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon