tc.h
#pragma once
char* fun();
tacc.c
#include<stdio.h>
char* fun()
{
printf("saDHAKJHFJ\n");
int i = 100;
printf("i = %d\n",i);
char* pr = (char *)malloc(100);
*pr = 20;
printf("*pr = %d\n", *pr);
printf("pr = %p\n", pr);
return pr;
}
main.c
#include<stdio.h>
//#include"tc.h"
int main()
{
printf("fun() = %p\n",fun());
//char* pn = fun();
//printf("pn = %p\n",pn);
//printf("*pn = %d\n", *pn);
return 0;
}
不同文件之间编译,要加头文件,不然tacc.c返回的地址会和活动打印的地址不一致