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
-------------------
#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语言指针使用方法
- Scala语言与Play框架入门教程
- GAWK 入门:AWK 语言基础
- C语言指针入门(一)
- em-lua语言入门学习视频。
- ZZ:使用.NET语言开发Silverlight应用程序入门(一):了解项目结构
- 菜鸟入门Java语言学习的要点
- R语言入门视频笔记--1
- C语言基础及指针②之指针内存分析
- Go语言中地址传递及指针的理解
- 关于C语言结构指针
- 南阳 oj 语言入门 笨小熊
- C 语言中什么是“句柄”和“指针”?“文件”和“流”又有什么异同?
- C 语言中的左值和右值。以及对比数组名和指针取数组元素的区别。
- 程序语言 -- Python入门
- 函数指针2017/12/2C语言学习内容总结
- 使用.NET语言开发Silverlight应用程序入门(一):了解项目结构
- c++入门学习笔记指针篇
- 直接定址表01 - 零基础入门学习汇编语言72
- C++基础入门教程(四):枚举和指针