c++ - ELI5 : What is the data type of `int *p[]`

标签 c++ c arrays pointers types

我不明白这是什么数据类型。如果它是一个指针或数组。请简单说明。引用书中的内容-

If you want to pass an array of pointers into a function, you can use the same method that you use to pass other arrays—simply call the function with the array name without any indexes. For example, a function that can receive array x looks like this:

void display_array(int *q[])
{
  int t;
  for(t=0; t<10; t++)
    printf("%d ", *q[t]);
}

Remember, q is not a pointer to integers, but rather a pointer to an array of pointers to integers. Therefore you need to declare the parameter q as an array of integer pointers, as just shown. You cannot declare q simply as an integer pointer because that is not what it is.

引用:C++:完整引用,第 4 版,Herbert Schildt,第 122-123 页

最佳答案

它是这样构建的:

  • int类型“int”。
  • int*类型“指向 int 的指针”
  • int* []类型“指向 int 的指针的数组(未知边界/长度)”
  • int* p[] 是上述类型的名为 p 的变量或参数的声明

关于c++ - ELI5 : What is the data type of `int *p[]` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53633122/

相关文章:

c++ - 我是否需要通过锁来保护对 Boost MultiIndex 索引(索引本身)的访问?

c++ - VS2010 - 如何查看程序的内存使用情况?

C编程指针和数组

arrays - 如何使用一系列交替的键和值来定义 Bash 5.1 关联数组?

python - 如何将 Python POST 数据转换为 JSON?

c++ - 混合 boost 库版本

c++ - 如何在 Windows 上安装 TensorFlow?

ctrl+c 不发送 SIGKILL 进行处理

c - 自动生成返回码校验工具

javascript - 更改两个数组总是同时更改另一个数组