您当前的位置:首页 > 计算机 > 编程开发 > C语言

看看C语言对变量及其地址和内容都进行了怎样的处理

时间:12-29来源:作者:点击数:

看看C语言对变量以及变量的地址和内容都进行了怎样的处理。

代码如下:

#include <stdio.h>
void moo(int a, int * b);
int main(void) {
    int x;
    int *y;
    x=1;
    y=&x;
    printf("Address of x = %d, value of x = %d\n", &x, x);
    printf("Address of y = %d, value of y = %d, value of *y = %d\n", &y, y, *y);
    moo(9,y);
}
void moo(int a, int *b){
    printf("Address of a = %d, value of a = %d\n", &a, a);
    printf("Address of b = %d, value of b = %d, value of *b = %d\n", &b, b, *b);
}

输出结果:

Address of x = 536869640, value of x = 1
Address of y = 536869632, value of y = 536869640, value of *y = 1
Address of a = 536869608, value of a = 9
Address of b = 536869600, value of b = 536869640, value of *b = 1
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门