仅在日食中出现此错误“不是结构或联合”

用户4861249

我只在 eclipse 中遇到这个错误。我的代码在其他编译器中运行时没有任何错误
这是我在 ECLIPSE 中遇到的错误

 21:20:16 **** Incremental Build of configuration Debug for project Sieve of Eratosthenes ****
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\Sieve of Eratosthenes.o" "..\\src\\Sieve of Eratosthenes.c" 
..\src\Sieve of Eratosthenes.c: In function 'main':
..\src\Sieve of Eratosthenes.c:16:15: error: request for member 'number' in something not a structure or union
   *(pri+(i-2)).number=i;
               ^
..\src\Sieve of Eratosthenes.c:17:15: error: request for member 'value' in something not a structure or union
   *(pri+(i-2)).value =1;
               ^
..\src\Sieve of Eratosthenes.c:20:23: error: request for member 'number' in something not a structure or union
   printf("%d",*(pri+i).number);
                       ^
..\src\Sieve of Eratosthenes.c:21:23: error: request for member 'value' in something not a structure or union
   printf("%d",*(pri+i).value);
                       ^

21:20:16 Build Failed. 4 errors, 0 warnings. (took 107ms)

我试图在“ https://www.onlinegdb.com/online_c_compiler ”中运行我的代码工作正常

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

struct prime {

        int number;
        int value;
    };

int main() {
    int n;
    printf("enter range");
    scanf("%d",&n);
    struct prime pri[n-2];
    for(int i=2;i<=n;i++){
        pri[i-2].number=i;
        pri[i-2].value =1;
    }
    for(int i=0 ;i<=n-2;i++){
        printf("%d ",pri[i].number);
    }

}
阿尔克

您面临的问题与 Eclipse 无关,而是与您在不同平台上使用的代码似乎不同这一事实有关。

*(pri+i).number

pri[i].number

不一样。

The.具有更高的优先级,因此它的绑定比*.

要使第一个版本工作,请执行以下操作:

(*(pri+i)).number

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

日食中出现未知错误。在cmd中完美运行

我在控制台中出现此错误:$(...).datepicker 不是函数

toDF 不是 Seq 的成员,在 Databricks 笔记本中出现此错误

为什么在SQL Server 2008中出现此错误:“列名不是定义的系统类型”?

为什么在Tensorflow中出现此错误?

参考错误:诺基亚未定义。仅在 Mozilla Firefox 浏览器中出现此错误

为什么我在日食时出现此错误

错误:[对象 HTMLDivElement]。在功能中出现此错误

仅在Chrome中出现错误:XMLHttpRequest无法加载资源

Yammer CORS错误仅在某些API调用中出现

仅在Firefox中出现Javascript参考错误

仅在发布版本中出现致命错误C1047

仅在Visual Studio Code中出现编译错误

仅在生产中出现Javascript错误

仅在docker环境中出现Python错误(名称或服务未知)

为什么数据类型转换错误仅在C ++中出现而不在C中出现?

错误401和403仅在Internet Explorer中出现(而不在Chrome,Firefox,..中出现)-IIS配置?

错误:不是结构或联合的成员,导致内存泄漏

成员“令牌”(不是结构或联合)的Yacc错误请求

错误:请求成员“ prev_”的原因不是结构或联合

是什么导致此代码中出现 int not subscriptable 错误?

在Play控制台kotlin中出现此错误。UninitializedPropertyAccessException

UnsatisfiedLinkError:在电报项目中出现此错误

为什么在SQL Server中出现此错误?

为什么在PHP if语句中出现此解析错误?

为什么我在Django中出现此错误?

在序言中出现错误“此位置的非法变量类型”

如何避免 Flutter EpubViewer 中出现此错误?

在 react js 中出现“this.props.sumOfPrices 不是函数”的错误?