'commit'
This commit is contained in:
26
TangDou/CSP-J/J1_2022/1_3_1.cpp
Normal file
26
TangDou/CSP-J/J1_2022/1_3_1.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int var = 20; // 实际变量的声明
|
||||
int *ip; // 指针变量的声明
|
||||
|
||||
ip = &var; // 在指针变量中存储 var 的地址
|
||||
|
||||
cout << "Value of var variable: ";
|
||||
cout << var << endl;
|
||||
|
||||
// 输出在指针变量中存储的地址
|
||||
cout << "Address stored in ip variable: ";
|
||||
cout << ip << endl;
|
||||
|
||||
cout << "Address stored in var variable: ";
|
||||
cout << &var << endl;
|
||||
|
||||
// 访问指针中地址的值
|
||||
cout << "Value of *ip variable: ";
|
||||
cout << *ip << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user