【发布时间】:2021-03-30 18:26:09
【问题描述】:
我想访问指向指针数组的指针
我成功地可以映射顶部和底部块
unsigned int *outputAddress = NULL;
unsigned int *outputOffsetAddress = NULL;
unsigned int *OutputptrptrAddr = NULL;
unsigned int *PtrArr[250];
unsigned int **val = PtrArr;
void MemoryMapping(unsigned int outputOffsetRTI)
{
unsigned int *memBase;
memBase = (unsigned int *)malloc(2000);
outputAddress = (unsigned int *)(memBase + outputOffsetRTI);
for (int x = 0; x < 5; x++)
{
*outputAddress = 123;
*outputAddress++;
}
outputAddress = outputAddress - 5;
for (int x = 0; x < 5; x++)
{
PtrArr[x] = (unsigned int *)outputAddress;
outputAddress += 1;
}
outputOffsetAddress = outputAddress + 250;
for (int x = 0; x < 5; x++)
outputOffsetAddress[x] = (unsigned int)PtrArr[x];
}
如何遍历输入指针块来获取输入块中的所有值?
【问题讨论】:
-
你展示的内容没有意义。
-
我有一个内存块分为两半,上半部分将包含值,而 bootm hal 将包含指向上半部分的指针。我想使用指向指针数组的指针访问上半部分
-
你可能是为什么不直接访问上半部分???这不是我们需要的:(
-
这似乎在做你想做的事,除了你没有分配适当的内存量。应该是
malloc(sizeof(int*) * (250 * 2 + outputOffsetRTI));此外,需要有某种方法可以让memBase在最后释放内存。 -
@siddharthtaunk 啊,您需要将
outputOffsetAddress定义为具有int **类型