将指针的二维数组传递给函数 C

编程入门 行业动态 更新时间:2024-10-27 15:19:10
本文介绍了将指针的二维数组传递给函数 C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个二维指针数组

main.c Int32 * pRxSeqAddr[2][2]; func(pRxSeqAddr);

/

func.c void func( Int32** pRxSeqAddrPtr) { /// }

我收到此错误:

argument of type "Int32 *(*)[2]" is incompatible with parameter of type "Int32 **

我知道如果它是一维指针数组,那么这个函数调用很好,但二维却让我烦恼..

I know if it was 1D array of pointer then this function call is fine, but 2D is nagging me..

请帮忙

推荐答案

将 func.c 更改为:

Change func.c to:

void func(Int32 *pRxSeqAddrPtr[][2]) { }

一般来说,要将二维数组传递给函数,您需要为除第一维之外的所有维度指定数组维度,因此在此示例中,最后一维需要 [2],但您可以选择将其省略为第一维,即

In general, to pass 2D arrays to functions you need to specify the array dimensions for all but the first dimension, so in this example you need the [2] for the last dimension but you can optionally omit it for the first dimension, i.e.

void func(Int32 *pRxSeqAddrPtr[2][2]) { }

也是有效的,但有点多余.

would also be valid, but somewhat redundant.

更多推荐

将指针的二维数组传递给函数 C

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

发布评论

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

>www.elefans.com

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