<分区>
好的,所以我很好奇您将如何使用指针数组访问索引中的值。例如:
printf("%c", (*character)[0]);
我知道我的代码有误,但我知道如何修复它。假设我想访问指针数组中的 0 位置,然后像上面那样打印它,我该怎么做?
<分区>
好的,所以我很好奇您将如何使用指针数组访问索引中的值。例如:
printf("%c", (*character)[0]);
我知道我的代码有误,但我知道如何修复它。假设我想访问指针数组中的 0 位置,然后像上面那样打印它,我该怎么做?
最佳答案
假设字符是 char character[] = {'1'};
character[someIndex] means someIndex[character] means *(character+someIndex)
如果那是您想知道的。所以你应该这样做:
printf("%c", *(character+0));
相当于
printf("%c", *character);
printf("%c", character[0]);
刚刚错过了 - 关于这个声明
index of a pointer array?
请知道Arrays are not Pointers .如果那是您感到困惑的地方。
关于c - 如何编辑指针数组的索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19064085/