无效类型参数 - > C结构 [英] Invalid type argument of -> C structs
本文介绍了无效类型参数 - > C结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图访问项目的结构数组并打印结构领域如下:
I am trying to access items in an array of structs and print the structs fields as follows
printList(Album *a, int numOfStructs)
{
int i;
int j;
for(i = 0; i < numOfStructs; i++)
{
printf("number%d\n:", i+1);
printf("%s", a[i]->field2);
printf("%s", a[i]->field2);
printf("%d", a[i]->field3);
for(j = 0; j < a[i]->numOfStrings; j++)
{
printf("%s", a[i]->strings[j]);
}
printf("\n");
}
}
但我得到的错误负荷这样
but I get loads of errors as such
无效类型参数 - >
我在做什么不对的指针?
What am I doing wrong with this pointer?
推荐答案
A
的类型为专辑*
这也就是说, A [I]
的类型为专辑
(这是 I
个元素专辑的阵列
对象通过指出,在 A
)。
a
is of type Album*
which means that a[i]
is of type Album
(it is the i
th element in the array of Album
object pointed to by a
).
的左操作数 - &GT;
必须是一个指针;在。
运算符使用,如果它不是一个指针。
The left operand of ->
must be a pointer; the .
operator is used if it is not a pointer.
这篇关于无效类型参数 - &GT; C结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文