Pointers
What you’ll learn:
o Introduction to pointers
o Pointers and arrays
o Pointers and functions
Introduction to Pointers
 A pointer is a variable that holds memory address of other variables.
 It always contains an unsigned int value (memory address cant be negative).
 The data type of pointer depends on the data type of variable it is pointing to.
How Pointers work
int a = 5;
int *ptr = &a;
5
10000
10000
12895
Memory Address of a
Value of a
Value of ptr
Memory Address of ptr
Variable name
Data type
Variable value
Address of
operator
Variable being
pointed to
Pointer
variable
Data type of
variable
being
pointed to
Indirection(or
value at address)
operator
&a *ptr ptr &ptra

7.pointers

  • 1.
    Pointers What you’ll learn: oIntroduction to pointers o Pointers and arrays o Pointers and functions
  • 2.
    Introduction to Pointers A pointer is a variable that holds memory address of other variables.  It always contains an unsigned int value (memory address cant be negative).  The data type of pointer depends on the data type of variable it is pointing to.
  • 3.
    How Pointers work inta = 5; int *ptr = &a; 5 10000 10000 12895 Memory Address of a Value of a Value of ptr Memory Address of ptr Variable name Data type Variable value Address of operator Variable being pointed to Pointer variable Data type of variable being pointed to Indirection(or value at address) operator &a *ptr ptr &ptra