您的位置:首页 > 编程语言 > C语言/C++

【ThinkingInC++】6、内存存放地址的地方

2014-08-10 10:56 375 查看
/**
* 功能:内存存放地址的地方
* 时间:2014年8月10日11:01:08
* 作者:cutter_point
*/

#include<iostream>

using namespace std;

//全局变量的存放地点
int dog, cat, bird, fish;

//函数存放内存地点
void f(int pet)
{
    cout<<"pet id number: "<<pet<<endl;
}

int main()
{
    int l, i, j, k;

    //依次输出地址位置
    cout<<"--------------------------------全局int----------------------------------"<<endl;
//    kk:
    cout<<"\n int dog:"<<(long)&dog
        <<"\n int cat:"<<(long)&cat
        <<"\n int bird:"<<(long)&bird
        <<"\n int fish:"<<(long)&fish<<endl;
    cout<<"--------------------------------函数----------------------------------"<<endl;
    cout<<"\n void f():"<<(long)&f<<endl;
//    goto kk;  这样果断死循环了
    cout<<"--------------------------------局部int----------------------------------"<<endl;
    cout<<"\n int i:"<<(long)&i
        <<"\n int j:"<<(long)&j
        <<"\n int k:"<<(long)&k<<endl;

//    cout<<"\n l:"<<(int)&l;

    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: