欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

C提高_day03_const小专题

发布时间:2025/6/17 编程问答 41 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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小专题的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。