Pointers Arithmetic
Pointers Arithmetic
Arithmetic
PF TEAM, FIT UCP
PAGE
Topics Heading
PAGE
Variables and Memory
Note: Computer’s memory is byte addressable i.e. every byte has an address
PAGE
Variables and Memory
9999
PAGE
Pointers
Pointer’s datatype is designed to hold the memory address
With pointers you can indirectly manipulate the content of other
variable
The pointer’s datatype and variable datatype should be same i.e.
integer pointer can not point to a character variable or vice versa
Right Wrong
If a pointer is pointing to a variable, it can access the value of that variable as well by
using de-reference operator i.e. asterisk *
Code Output on Console
Note: Number added or subtracted from the pointer’s value solely depends upon the datatype of pointer
PAGE
Variablesand
Pointers andArrays
Memory
th
Name of the array is the address of 0 index of array
Array name can be used as constant pointer, and pointers can be
used as array names
Pointer arithmetic is very important while manipulation array
PAGE
Use of Array as Pointer
int arr[6] = {10, 20, 30, 40, 50, 60}
int *ptr = arr; //ptr pointing to arr
PAGE
int arr[6] = {10,20,30,40,50,60}
VariablesHitch
Pointers and Memory
Hikes int *ptr;
ptr = arr; // ptr1 = &arr[0]
*++ptr//equivalent of *(++ptr) st
1 increment ptr then dereference the pointer
PAGE
Points to ponder