-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleHeader.h
More file actions
45 lines (35 loc) · 1.16 KB
/
simpleHeader.h
File metadata and controls
45 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;
int PtrFun(int a){ cout << "magic access: to" << &PtrFun << endl << "Value passed is: " << a;
}
int Pointer2Pointer(){
int var = 300;
int *ptr;
int **pptr;
}
int Func(){
const int SIZE = 8;
int array[SIZE] = {5, 10, 15, 20, 25, 30, 35, 40};
int leaks = 69;
int *numPtr = nullptr;
int count;
//cout << "pointers address is: " << &numPtr << endl;
//cout << *numPtr << " dereffed. value is: " << numPtr << endl;
numPtr = array;
cout << *numPtr << " dereffed. value is: " << numPtr << endl;
//display address of first element
cout << numPtr << endl;
//use pointer to display array's contents
for(count = 0; count < SIZE; count++){
cout << *numPtr << " is the value, address is: " << numPtr << endl;
numPtr++;
}
//Going out of bounds on array to access areas of memory we shouldn't, including other variables in memory.
for(count = 0; count < 4; count++){
cout << *numPtr << " is dereferenced, address is: " << numPtr << endl;
numPtr++;
}
cout << "Address of leaks is: " << &leaks << endl;
auto PtrFun1 = PtrFun;
cout << &PtrFun1;
}