forked from rikardgn/learnCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintPtr.cpp
More file actions
19 lines (18 loc) · 714 Bytes
/
intPtr.cpp
File metadata and controls
19 lines (18 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//Simple example how to create a pointer to int
#include <iostream>
using namespace std;
int main(void){
int* ptrToInt;
int num=20;
ptrToInt=#
//printing of values
cout << "The variable num has the value:" << "\n";
cout << num << "\n";
cout << "The pointer ptrToInt contains the adress of num and thus points to the variable num" << "\n";
cout << "Contents of ptrToInt:" << "\n";
cout << ptrToInt << "\n";
cout << "By using the derefeence operator you can find the value cotained at the adress of the var num" << "\n";
cout << "By using the derefrence operator on the pointer ptrToInt you vill get the value:" << "\n";
cout << *ptrToInt << "\n";
return 0;
}