malloc01.cpp
来自「数据结构常用算法合集」· C++ 代码 · 共 17 行
CPP
17 行
//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 + =
减小字号Ctrl + -
显示快捷键?