-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntrotoPointer.cpp
66 lines (51 loc) · 1.17 KB
/
IntrotoPointer.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<iostream>
using namespace std;
int main () {
//pointer to int is created, and pointing to some garbage address
//int *p = 0;
//cout << *p << endl;
/*
int i = 5;
int *q = &i;
cout << q << endl;
cout << *q << endl;
int *p = 0;
p = &i;
cout << p << endl;
cout << *p << endl;
*/
// int num = 5;
// int a = num;
// cout << "a before " << num << endl;
// a++;
// cout << "a after " << num << endl;
// int *p = #
// cout << "before " << num << endl;
// (*p)++;
// cout << "after " << num << endl;
//copying a pointer
// int *q = p;
// cout << p <<" - " << q << endl;
// cout << *p <<" - " << *q << endl;
// //important concept
// int i = 3;
// int *t = &i;
// //cout << (*t)++ << endl;
// *t = *t +1;
// cout << *t << endl;
// cout << " before t " << t << endl;
// t = t + 1;
// cout << " after t " << t << endl;
// float f =10.5;
// float p =2.5;
// float*ptr =&f;
// cout<<*ptr<<endl;
// (*ptr)++;
// *ptr =p;
// cout<<*ptr<<" "<<f<<" "<<p<< endl;
int *ptr =0;
int a =10;
//*ptr =a;
cout<<*ptr;
return 0;
}