C提高_day03_const小专题
生活随笔
收集整理的這篇文章主要介紹了
C提高_day03_const小专题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
const int a;???? //代表整型變量a不能被修改
int const b;
?
const char *c;? //看const 是放在*的左邊還是右邊 看const是修飾指針變量,還是修飾所指向的內存空變量
char * const d; char buf[100]
#include <stdio.h> #include <stdlib.h> #include <string.h>void main() {const int a=10;//a=11;int *p;{p=&a;*p=100; //通過指針可以修改a的值printf("a:%d \n",a);}system("pause");return; } #include <stdio.h> #include <stdlib.h> #include <string.h>void getmem1(char *p) {//p=1;//p=3;// p[1]='a';return; }void getmem2(char * const p) {p=1;p=3;// p[1]='a';return; }void main() {char *p1= NULL;const char *p2= NULL;p2=1;printf("helllo...\n");system("pause");return; }轉載于:https://www.cnblogs.com/zhesun/p/4959860.html
總結
以上是生活随笔為你收集整理的C提高_day03_const小专题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 祝各位节日快乐!20151111
- 下一篇: 个人阅读作业Week7