您的位置:首页 > 其它

c 语言入门指针

2012-06-26 16:29 120 查看
测试代码

#include <stdio.h>

int a =112,b =-1;
float c= 3.14;
int *h = &a;
float *e = &c;

int x = 12;
int *y = &x;
int **z = &y;

char ch = 'a';
char *cp = &ch;

main(){
int *w = malloc(sizeof(int));
memset(w, 0, sizeof(int));
int u =4;
memcpy(w, &u, sizeof(int));
printf("%d\n",*w);
free(w);
printf("%s\n","-------------------");
printf("%ld\n",&a);
printf("%d\n",*h);
printf("%d\n",h);
printf("%d\n",e);
printf("%s\n","-------------------");
printf("%d\n",(int)*(&x));
printf("%d\n",(int)*(y));
printf("%d\n",(int)*(*z));
printf("%s\n","-------------------");
printf("%c\n",(char)*(cp));
printf("%c\n",(char)++*(cp));
printf("%c\n",(char)*(cp)++);
printf("%s\n","-------------------");
}

打印出来的值

4
-------------------
134520872
112
134520872
134520880
-------------------
12
12
12
-------------------
a
b
b
-------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  语言 c float 测试