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

时间:2015-09-22 15:02:08

标签: c arrays double

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

  

ass1cpy.c:在功能' player_data':
  ass1cpy.c:26:46:警告:变量&得分'设置但未使用[-Wunused-but-set-variable]
    double average_goals,average_shots,effIndex,得分[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;
}

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

1 个答案:

答案 0 :(得分:2)

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