#include<Windows.h>
#include <iostream>
using namespace std;
char* test() {
//char p[1024] = {0};//函数调用完毕后就释放掉内存
char* p = new char[1024];
sprintf_s(p,1024,"你好%d", 2020);
return p;
}
int main() {
char* p ;
p=test();
cout << p << endl;
char p1[1024] = { 0 };
sprintf_s(p1, 1024, "你好%d", 2020);
cout << p1 << endl;
system("pause");
return 0;
}
20200112 好好体会下,什么叫做函数的栈帧调用,什么是局部变量的生命周期
最新推荐文章于 2022-09-08 14:34:38 发布