0
点赞
收藏
分享

微信扫一扫

20241010_003117 c语言 体验函数中局部变量地址的消失

函数中的变量有生命 函数执行完毕后 就失去生命 内存地址也会消失 如果返回了函数中变量的指针 可能会存在问题 本例子展示问题

#include <stdio.h>  
#include <stdlib.h>
#include <time.h>


int* fn(){
int a = 10;
return
}

int main() {

int * b;
b = fn();
printf(hi);
printf(hi);
printf(%d,*b);

return 0;
}



举报

相关推荐

0 条评论