gpt4 book ai didi

c - 如何在 C 中传递 3 维数组的地址?

转载 作者:行者123 更新时间:2023-11-30 18:02:18 24 4
gpt4 key购买 nike

我有 4 个“#defines”:

    #define MAX_NO_OF_ROUTES    15
#define MAX_STOPS_IN_ROUTE 50
#define RAIL_SYMBOL_LEN 3
#define READ_ADDR 25236

我有一个像这样声明的 3 维数组:

    unsigned char ram_route_info[MAX_NO_OF_ROUTES][MAX_STOPS_IN_ROUTE][RAIL_SYMBOL_LEN];

我有一个“for”循环,如下所示:

    for(i = 0 ; i < MAX_NO_OF_ROUTES ; ++i)
{
for(j = 0 ; j < MAX_STOPS_IN_ROUTE ; ++j)
{
// read from Flash into ram !!
HL_flash2ram(READ_ADDR, &ram_route_info[i][j][0]);
}
}

“HL_flash2ram”函数原型(prototype)为

    void HL_flash2ram(long addr, unsigned char* );

但是,在编译时,我收到警告:

    warning C182: pointer to different objects

我使用的是KEIL编译器。我什至尝试过以下方法:

    ram_route_info[i][j]
&(ram_route_info[i][j])
ram_route_info[i][j][0]

有什么问题吗?

最佳答案

您可以将其作为“无符号字符*”传递。 (即三个星号)

关于c - 如何在 C 中传递 3 维数组的地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9239348/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com