Files
homework/指针/指针和数组的地址.cpp

20 lines
537 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
1 #include<iostream>
2 using namespace std;
3
4 int main(){
5
6 int a=10;
7 int b[5]={10,20,30,40,50};
8 int * ptr_a , * ptr_b;
9
10 ptr_a=&a;
11 ptr_b=b;
12 cout << "我是内存地址: "<<ptr_a <<" 我是地址内的值 "<< * ptr_a<<endl;
13 cout << "我是内存地址: "<<ptr_b <<" 我是地址内的值 "<< * ptr_b<<endl;
14
15 for (int i=0;i<5;i++)
16 cout << "我的地址:"<< ptr_b+i<<endl;
17
18 return 0;//这个可以省略
19
20 }