#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void test01(){
char *p = malloc(sizeof(char)*64);
//利用临时的指针,操作里面的内存
char *pp = p;
for (int i = 0; i < 10; i++){
*pp = i + 97;
printf("%c\n",*pp);
pp++;//申请的首地址指针偏移后,就不可以利用这个指针释放堆区内存了
}
if (p != NULL){
free(p);
p= NULL;
}
}
int main(){
test01();
return 0;
}
指针的易错点
猜你喜欢
转载自blog.csdn.net/qq_39112646/article/details/102712750
今日推荐
周排行