C 无效的类型参数'-&燃气轮机';(具有';int';)

C 无效的类型参数'-&燃气轮机';(具有';int';),c,pointers,dereference,operator-precedence,invalid-argument,C,Pointers,Dereference,Operator Precedence,Invalid Argument,我在编译代码时收到下面报告的错误。你能纠正我哪里弄错了吗 ->的类型参数无效(haveint) 我的代码如下: #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> typedef struct bundles { char str[12]; struct bundles *right; }bundle; int main

我在编译代码时收到下面报告的错误。你能纠正我哪里弄错了吗

->
的类型参数无效(have
int

我的代码如下:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

typedef struct bundles
    {
    char str[12];
    struct bundles *right;
}bundle;

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */    
    unsigned long N;
    scanf("%lu", &N);
    bundle *arr_nodes;
    arr_nodes = malloc(sizeof(bundle)*100);
    int i=5;
    for(i=0;i<100;i++)
    {
    scanf("%s", &arr_nodes+i->str);
    printf("%s", arr_nodes+i->str);
    }
    return 0;
}
你是说

scanf("%s", (arr_nodes+i)->str);
如果没有括号,
->
运算符被应用于
i
而不是增加的指针,则该符号通常会令人困惑,特别是因为

scanf("%s", arr_nodes[i].str);
我也会这么做

您还应该检查
malloc()
是否未返回
NULL
,并验证
scanf()
是否成功扫描。

您需要

scanf("%s", (arr_nodes+i)->str);
printf("%s", (arr_nodes+i)->str);
您的原始代码与相同

scanf("%s", &arr_nodes+ (i->str) );
因为
->
的优先级高于
+
,所以您会得到该错误。

根据,
->
的优先级高于
+
。您需要将代码更改为

scanf("%s", (arr_nodes+i)->str);

谢谢你,伊哈罗布。成功了。我不知道括号里有什么。现在有道理了。
scanf("%s", (arr_nodes+i)->str);