程序1:

//2022年9月20日22:06:27
#include <iostream>
#pragma warning(disable:4996)
using namespace std; //1.new创建基础类型的数组
void test01()
{
//申请基础数据类型的数组
int * pInt = new int [10] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};//不推荐
for (int i = 0; i < 10; i++)
{
pInt[i] = i + 1;
} for (int i = 0; i < 10; i++)
{
cout << pInt[i] << " ";
}
cout << endl; char * pChar = new char[64];
memset(pChar, 0, 64);
strcpy(pChar, "小花");
cout << pChar << endl; //注意:如果new时有中括号,那么delete时也要有中括号
delete [] pInt;
delete [] pChar;
}
int main()
{
test01();
system("pause");
return EXIT_SUCCESS;
}

输出结果:

1 2 3 4 5 6 7 8 9 10
小花
请按任意键继续. . .

最新文章

  1. asp.net中如何防止用户重复点击提交按钮
  2. STP的作用和操作
  3. [10]APUE:信号
  4. Oracle开发常用函数与存储过程
  5. C语言 百炼成钢16
  6. C#中virtual和abstract的区别
  7. POJ 3468 A Simple Problem with Integers (伸展树区间更新求和操作 , 模板)
  8. tomcat7 1000并发量配置 tomcat7配置优化
  9. 最简单的视音频播放示例6:OpenGL播放YUV420P(通过Texture,使用Shader)
  10. HDU 4009 Transfer water 最小树形图
  11. Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET
  12. Oracle学习第二天
  13. 设置int、float型数据的输出格式
  14. (详细)php实现留言板---会话控制-----------2017-05-08
  15. 常见C++面试题及基本知识点总结(一)
  16. Docker入门书籍
  17. Codeforces 842B Gleb And Pizza【几何,水】
  18. arm_linux_device_mem内存映射
  19. IntelliJ IDEA 源值1.5已过时,将在未来所有版本中删除
  20. C++关于Union使用的部分总结

热门文章

  1. Ubunutu的apt-get软件下载工具的国内镜像源
  2. [2007年NOIP普及组] 纪念品分组
  3. react常见bug - 查询条件变化,但page未重置为1
  4. 【APT】APT-C-41下载器组件样本分析
  5. 开始 go
  6. Debug --&gt; python中的True False 0 1
  7. What is the Best Python IDE for Data Science?
  8. PTA1003 我要通过! (20 分)
  9. UI自动化之【maven+selenium环境搭建】
  10. 第14章 身份验证:使用Identity将用户添加到应用程序(ASP.NET Core in Action, 2nd Edition)