Check50 似乎没有编译,而 clang 和 make 没有显示错误

Check50 doesn't seem to compile while clang and make show no errors

我是 edx;s cs50 online 的一员 course.Right 现在我在第 3 周并尝试解决复数问题(This is the link to the page)。代码似乎可以完美运行并且可以通过 clang 进行编译和 make(cs50 的帮助工具之一)。但是当我尝试使用 check50 cs50/problems/2020/x/plurality 检查我的代码时,它说它不能 compile.Here 是我编写的代码。 我用c写的。

#include <cs50.h>
#include <stdio.h>
#include <string.h>

// Max number of candidates
#define MAX 9

// Candidates have name and vote count
typedef struct
{
    string name;
    int votes;
}
candidate;

// Array of candidates
candidate candidates[MAX];

// Number of candidates
int candidate_count;

// Function prototypes
bool vote(string name,int candlen);
void print_winner(int candlen);

int main(int argc, string argv[])
{
    // Check for invalid usage
    if (argc < 2)
    {
        printf("Usage: plurality [candidate ...]\n");
        return 1;
    }

    // Populate array of candidates
    candidate_count = argc - 1;
    if (candidate_count > MAX)
    {
        printf("Maximum number of candidates is %i\n", MAX);
        return 2;
    }
    for (int i = 0; i < candidate_count; i++)
    {
        candidates[i].name = argv[i + 1];
        candidates[i].votes = 0;
    }

    int voter_count = get_int("Number of voters: ");

    // Loop over all voters
    for (int i = 0; i < voter_count; i++)
    {
        string name = get_string("Vote: ");


        // Check for invalid vote
        if (!vote(name,candidate_count))
        {
            printf("Invalid vote.\n");

        }

    }

    // Display winner of election
    print_winner(candidate_count);
}

// Update vote totals given a new vote
bool vote(string name,int candlen)
{
    for (int i = 0; i < candlen; i++)
    {
        if (strcmp(candidates[i].name,name)==0)
        {
            candidates[i].votes++;
            return true;
        }
    }
    return false;
}

// Print the winner (or winners) of the election
void print_winner(int candlen)
{

    int Present_best = 0;
    for (int i = 0; i < MAX; i++)
    if (candidates[i].votes != 0)
    {
        if (candidates[i].votes>candidates[Present_best].votes)
        {
            Present_best = i;
        }
    }

    for (int i = 0;i<candlen;i++)
    {
        if (candidates[i].votes == candidates[Present_best].votes)
        printf("%s\n",candidates[i].name);
        }
    return;
}

来自规范:

You should not modify anything else in plurality.c other than the implementations of the vote and print_winner functions (and the inclusion of additional header files, if you’d like).

这些是 provided/required 函数签名:

// Function prototypes
bool vote(string name);
void print_winner(void); 

这个要求可能看起来很严格或苛刻。虽然这里唯一的关键是成绩,但如果不遵循老板或客户提供的规格,它可能会转化为真金白银。