编译器没有看到我的元素被添加到我的数组中

标签 c arrays double

这是代码的一部分。我一直尝试编译,但它一直给我这个错误。是不是赋值语句有问题?

ass1cpy.c: In function 'player_data':
ass1cpy.c:26:46: warning: variable 'score' set but not used [-Wunused-but-set-variable]
double average_goals,average_shots,effIndex,score[MAX];

int
player_data(void){
    char name[MAX];
    int maxgames,playerId,games,minutes,goals,shots,assists,yellowCards,
    redCards,checker = 0, i = 0;
    double average_goals,average_shots,effIndex,score[MAX];
    scanf("%d",&maxgames);
    while(scanf("%d %d %d %d %d %d %d %d     %s",&playerId,&games,&minutes,&goals,&shots,
        &assists,&yellowCards,&redCards,name) == 9){
    average_goals = goal_average(goals,games);
    average_shots = shots_average(shots,goals);
    effIndex = effIndex_cal(goals,assists,redCards,yellowCards,games,maxgames);
    if(checker == 0){
        printf("Player %d scored %d goals in %d minutes from %d games\nGoals     per"
            " game: %05.2f\nShots per goal: %05.2f\nEffindex:     %05.2f\n",playerId,
            goals,minutes,games,average_goals,average_shots,effIndex);
    }
    checker = 1;
    score[i] = effIndex
    i++;
        }
        return 0;
}

如何更改它以便可以编译?

最佳答案

这不是一个错误。这是一个警告。它警告您正在分配一个变量,但从未使用过该变量。它警告您这一点,因为这很可能是一个问题。

关于编译器没有看到我的元素被添加到我的数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32720349/

相关文章:

c - C语言中如何获取内存地址的值

c - 下标值既不是数组也不是指针

c - 我动态分配的结构体指针数组有什么问题?

Java,scan double只接受int

Java - 一次双加法/减法的最大精度损失

c - 为什么inc/hw_ints.h打不开?

c - 如何在没有相同引用的情况下将文本文件中的字符串存储在 C 中?

javascript - 新手 JS 寻求帮助来完成练习

java - 在二维数组中使用 split() 方法?

ubuntu - 在 ubuntu 14.04 服务器下,双数乘法在 Grails 中不起作用