forked from Jingchaofeng/3035
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointers.cpp
42 lines (30 loc) · 879 Bytes
/
pointers.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
#include <iostream>
using namespace std;
int main ()
{
float stuff[100];
float *p;
stuff[5] = 10;
p = stuff;
cout << stuff << '\n';
cout << p << '\n';
cout << stuff[1000] << '\n';
// int x = 10;
// int* pointerToX = &x;
// int* messedUpPointer = pointerToX - 1000000000;
// *messedUpPointer = 300000000;
// cout << *messedUpPointer << '\n';
// int firstvalue, secondvalue;
// firstvalue = 10;
// cout << "location of secondvalue is " << &secondvalue << '\n';
// // cout << "location of firstvalue is " << &firstvalue << '\n';
// int * mypointer;
// mypointer = &firstvalue;
// // cout << "value of mypointer is " << mypointer << '\n';
// *mypointer = 15;
// mypointer = &secondvalue;
// *mypointer = 20;
// cout << "firstvalue is " << firstvalue << '\n';
// cout << "secondvalue is " << secondvalue << '\n';
return 0;
}