摘要: /* 2020,6,20,动态构建一维数组 str = (char *) realloc(str, 25);动态调整分配的内存大小 */ #include<stdio.h> #include<malloc.h> int main(void) { int a; int * li; printf("请输 阅读全文
posted @ 2020-07-06 20:29 河马哥 阅读(866) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int main(void) { int li[2][3] = { {1,2,3}, {11,22,33} }; int *p; //第一种 p = &li[0][0]; for(int i = 0; i < 6; i++) { //printf("%d\n",p 阅读全文
posted @ 2020-07-06 20:00 河马哥 阅读(244) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int main(void) { //指向常量的指针:const 类型 * 指针名 int i = 10; const int *p = &i; //*p = 0; //报错 printf("%d\n",*p); //总结,前置const不能通过指针改变指向的地址 阅读全文
posted @ 2020-07-06 17:04 河马哥 阅读(248) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int main(void) { //指针的运算 int * p; p = NULL; //表示是个空指针 p++; //p = p + 1,p的值是0加上sizeof(int)*1 printf("加运算:%d\n",p); //结果是4,因为int类型占用4个 阅读全文
posted @ 2020-07-06 16:44 河马哥 阅读(373) 评论(0) 推荐(0) 编辑