-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointer.cpp
54 lines (45 loc) · 1.41 KB
/
pointer.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
#include <iostream>
#include <cstring>
int main() {
using namespace std;
// &桶尨華硊 *桶尨硌渀 硌渀硌砃華硊 *pointer桶尨鳳腕華硊揣湔腔硉
int noob = 17900;
int* pointer = &noob;
int p_noob = noob;
cout << "pointer address is " << pointer << endl;
cout << "pointer value is " << *pointer << endl;
cout << &noob << endl;
cout << noob << endl;
cout << &p_noob << endl;
cout << p_noob << endl;
//繹撼
enum spectrum { dd = 1, cl, ca, bb, cv };
cout << dd << cl << ca << bb << cv << endl;
int* noobs = new int[3];
noobs[0] = 100700;
noobs[dd] = 17900;
noobs[cl] = 21400;
//硌渀+1脹衾華硊痄雄
cout << "noob dd have " << noobs[dd] << " hp." << endl;
cout << "show noob dd's address :" << (int*)noobs[dd] << endl;
noobs = noobs + dd;
cout << "next match noob dd have " << noobs[dd] << " hp.lucky." << endl;
cout << "show noob dd's address :" << (int*)noobs[dd] << endl;
noobs = noobs - dd;
cout << "this match noob dd have " << noobs[dd] << " hp.wtf is it?" << endl;
cout << "show noob dd's address :" << (int*)noobs[dd] << endl;
delete[] noobs;
//cout << noobs[1];
cout << endl;
//strcpy
char noobteam[20] = "shimakaze";
char shima[20] = "shitmakaze";
char* teammate ;
teammate = new char[strlen(noobteam)+1];
strncpy(teammate,noobteam,5);
cout << teammate << endl;
strncpy(teammate,noobteam,10);
cout << teammate;
delete teammate;
return 0;
}