指针与数组

#include <iostream>
using namespace std;

int main()
{
 int age = 30;
 int mynumbers[3] = {1,2,3};   

 int* garbage = NULL;
 int *point = &age;
 int *test  = mynumbers;  //可将数组变量赋给类型与之相同的指针。

 cout << "the garbage is at: " << garbage << endl;
 cout << "the age is at: " << point << endl;
 cout << "the test is at: " << test << endl;
 cout << "the test is : " << test[0] << endl;
 cout << "the test is : " << test[1] << endl;
 cout << "the test is : " << test[2] << endl;

 return 0;

}

    

the garbage is at: 0
the age is at: 0x7ffccf9ee444
the test is at: 0x7ffccf9ee460
the test is : 1
the test is : 2
the test is : 3

  

posted on 2019-08-14 16:13  cdekelon  阅读(48)  评论(0)    收藏  举报

导航