c++ - 这两个语句是什么意思 char (*test)[10]; 测试=新字符[4][10];
问题描述
在 C++ 中
char (*test)[10];
test = new char[4][10];
以上两个声明的含义是什么?
解决方案
char (*test)[10];
第一行声明test
为指向char[10]
.
test = new char[4][10];
第二行创建一个char[4][10]
具有 4 个类型元素的数组char[10]
,并将指向该数组第一个元素的指针分配给test
。
它类似于
T* test; // pointer to T
test = new T[4]; // create array with 4 elements
// and assign pointer to first element to test
推荐阅读
- python-3.x - 如何在组之间找到共同的元素集?
- java - 如何为 FileOutputStream 设置动态路径名?
- kubernetes - 使用 Nginx-Ingress 的 kubernetes NodePort 与 ClusterIP
- github - 如何使用graphql按更新日期过滤github拉取请求?
- mysql - Oracle同步中的Varchar(20字节)到Mysql varchar(20)?
- c - 读取文件时使用 fgets() 忽略换行符
- javascript - TextInput 样式问题 - CSS - React Native
- python - 在 OpenCV 中用轴绘制图像
- analytics - Amplitude & Segment.io - Saas 产品分析 - 如何获得所有用户
- python - 程序不将字符串与文本文件中的单词匹配