📄 malloc01.cpp
字号:
//malloc01.cpp
#include <iostream.h>
#include <conio.h>
#include <alloc.h>
#include <process.h>
void main()
{ char *str;
if ((str = (char *) malloc(11)) == NULL)
{ cout << "内存不足\n";
exit(1);
}
strcpy(str,"Nice");
cout << "数据为:"<<str<<endl;
free(str);
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -