const限定符和指针的用法实例
来源:互联网 发布:python在spss中的应用 编辑:程序博客网 时间:2024/05/23 16:05
刚开始看《Effective C++》这本书,里面讲到const。我按照书上讲的,简单的写了个例子。如下。备忘。
#include <stdio.h>int main(){/*//下面const的用法表示const修饰的是p所指向的值是常量int i = 10;int k = 20;const int *p = &i;printf("%x\n",p);//*p = 20; //这一句是错误的,*p所指向的值是常量p = &k;printf("%x\n",p);printf("%d",*p);*///下面演示const修饰指针本身的情况int m = 100;int n = 200;char * const p = (char * const)&m; //如果不加(char * const)会提示错误printf("%x\n",p);printf("%d\n",*p);//p = (char * const)&n; //提示错误,不能给常量p赋值*p = 50;printf("%x\n",p);printf("%d\n",*p);getchar();return 0;}
1 0
- const限定符和指针的用法实例
- 指针和const限定符
- 指针和const限定符
- 指针和const 限定符
- 指针和const限定符
- const限定符和指针
- 指针和const限定符
- 指针和const限定符
- 指针和const限定符
- 指针和const限定符
- 指针和const限定符
- 指针和const限定符
- 指针和const限定符
- 指针和const限定符
- 指针和const限定
- C++基础:指针和const限定符
- 指针和const限定符搭配
- C++中const限定符和指针
- hbase-java-client
- 2014年下半年计划
- 杭电2135 仙人球的残影
- 基于UDP协议的局域网网络聊天工具
- 成都传智播客Java/PHP培训就业率高
- const限定符和指针的用法实例
- 使用Linkify来检测一些链接
- WPS分为PBC(BUTTON)和PIN两种方式
- 左中右布局经典案例
- hadoop-fs-java-client-test
- linux 查看物理cpu个数、核数、逻辑cpu个数
- C#多线程转载一篇
- linux服务器下tomcat启动日志记录乱码
- 我们到了冷淡期 过20我留住她 我还爱她