C语言定义变量,分配内存时采用的是栈模式,于是乎,就有了如此如此,这般这般的效果
#include<iostream>
using namespace std;
int main()
{
int a = 66666;
int b = 22222;
int c[2] = {333333,44444};
cout << " 修改前的值 " << endl;
cout << " c[2]= " << c[2] << endl;
cout << " c[3]= " << c[3] << endl;
c[3] = 12345; //修改c[3]的值
cout << "修改后的值:" <<endl;
cout << " c[3]= "<< c[3] << endl;
cout << " a= "<< a << endl;
return 0;
}
同理,我们可以利用指针这种东西,如下
#include<iostream>
using namespace std;
int main()
{
int a = 0;
int *p = &a;
for(int i=0;i<10;i++)
{
cout << p << " : ";
cout << *p++ << endl;
}
return 0;
}