Nearby lessons
53 of 72C - Pointer Introduction
A pointer is a variable that stores the memory address of another variable. In this lesson, you will learn the basic meaning of pointers, how to declare them, and how to get a variable's address.
What Is a Pointer?
A normal variable stores a value. A pointer stores the memory address where another variable is stored.
For example, int *ptr declares a pointer that can store the address of an integer variable.
Example01
Memory Address and the & Operator
Every variable has a memory address. Use the & operator to get that address.
Memory addresses can change between program runs, so your output may show a different address.
Example02
Pointer Declaration and Initialization
Use type *pointerName; to declare a pointer. It is better to give it a valid address when you create it.
Example03
📝 Key Takeaways
- A normal variable stores a value.
- A pointer stores an address.
- The & operator gives the address of a variable.
- The * symbol is used when declaring a pointer.
- Use %p to display an address.
🧠 Test Your Knowledge
2 QuestionsProgress: 0 / 2