相关疑难解决方法(0)

无效的类型参数 - > C结构

我试图访问结构数组中的项目并打印结构字段,如下所示

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");
    }
}
Run Code Online (Sandbox Code Playgroud)

但我得到了很多错误

" - >"的无效类型参数

这个指针我做错了什么?

c pointers

28
推荐指数
2
解决办法
7万
查看次数

错误:'unary*'的无效类型参数(有'int')

我有一个C程序:

#include <stdio.h>
int main(){
  int b = 10;             //assign the integer 10 to variable 'b'

  int *a;                 //declare a pointer to an integer 'a'

  a=(int *)&b;            //Get the memory location of variable 'b' cast it
                          //to an int pointer and assign it to pointer 'a'

  int *c;                 //declare a pointer to an integer 'c'

  c=(int *)&a;            //Get the memory location of variable 'a' which is
                          //a pointer to 'b'.  Cast that to an int pointer 
                          //and assign it to …
Run Code Online (Sandbox Code Playgroud)

c pointers

26
推荐指数
3
解决办法
13万
查看次数

标签 统计

c ×2

pointers ×2