Pointers in C
Introduction, Types, and Function
Usage
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.
Declaring Pointer Variables
• • Syntax: data_type *pointer_name;
• • Example:
• int *ptr;
• char *cptr;
• • '*' is used to declare a pointer.
Types of Pointers
• • NULL Pointer
• • Void Pointer
• • Wild Pointer
• • Dangling Pointer
• • Function Pointer
• • Pointer to Pointer
Passing Arguments using Pointers
• • 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;
• }

pointer in c programming for second semester

  • 1.
    Pointers in C Introduction,Types, and Function Usage
  • 2.
    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; • }