簡體   English   中英

編譯器沒有看到我的元素被添加到我的數組中

[英]Compiler does not see my element being added into my array

這是代碼的一部分。 我一直在嘗試編譯,但它一直給我這個錯誤。 賦值語句有問題嗎?

ass1cpy.c:在函數“player_data”中:
ass1cpy.c:26:46: 警告:變量 'score' 設置但未使用 [-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;
}

我該如何更改它以便它可以編譯?

這不是錯誤。 這是一個警告。 它警告您正在分配一個變量,但從未使用過。 它向您發出警告,因為這很可能是一個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM