Lec 04 Pointers
Lec 04 Pointers
Lecture 4: Pointers
khari.armih@gmail.com
June 9, 2023
int x = 3;
int *ptr;
int x = 3;
int *ptr;
ptr = &x;
int num;
int * numPtr;
numPtr = &num
• You can print the address stored in a pointer using:
char c = ’A’;
char *cPtr;
cPtr = &c;
*cPtr = ’B’;
int arr[5];
• arr is like a pointer to element 0 of the array:
int arr[10];
• can be passed to a function as follows:
func(arr,10);
9 int main()
10 {
11 int a[100];
12 cout << sizeof(a) << " ";
13 findSize(a);
14 return 0;
15 }