数组int(* ptr)[10]的指针是什么,它是如何工作的?

编程入门 行业动态 更新时间:2024-10-26 18:17:55
本文介绍了数组int(* ptr)[10]的指针是什么,它是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 int (*ptr)[10];

我期望 ptr 是一个由 10 个整数组成的指针数组.

I was expecting ptr to be an array of pointers of 10 integers.

我不明白它是如何指向 10 整数数组的指针.

I'm not understanding how it is a pointer to an array of 10 integers.

推荐答案

ptr 类型为指向10个整数的数组的指针".在您的声明中,它是未初始化的,因此它不会指向任何对象.使其指向数组:

ptr is of type "pointer to array of 10 int". In your declaration it is uninitialized so it doesn't point to any object. To make it point to an array:

int arr[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; // initialize in the declaration: int (*ptr) [10] = &arr; // or after: int (*ptr) [10]; ptr = &arr;

更多推荐

数组int(* ptr)[10]的指针是什么,它是如何工作的?

本文发布于:2023-07-29 08:37:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1239139.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:它是   数组   指针   工作   int

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!