Introduction to Pointers
•• A pointer is a variable that stores the
address of another variable.
• • Provides direct access to memory.
• • Useful for dynamic memory, arrays, and
functions.
3.
Declaring Pointer Variables
•• Syntax: data_type *pointer_name;
• • Example:
• int *ptr;
• char *cptr;
• • '*' is used to declare a pointer.
4.
Types of Pointers
•• NULL Pointer
• • Void Pointer
• • Wild Pointer
• • Dangling Pointer
• • Function Pointer
• • Pointer to Pointer
5.
Passing Arguments usingPointers
• • Functions can accept pointers as arguments.
• • Allows modification of actual variables.
• • Example:
• void swap(int *a, int *b) {
• int temp = *a;
• *a = *b;
• *b = temp;
• }