为什么我的 C 代码不断返回“预期表达式”错误消息

问题描述 投票:0回答:0

为什么我的 C 代码不断返回 '22:1: 错误:预期表达式 }'?我是这门语言的新手,我已经检查了好几次格式,但仍然没有得到任何线索。如果有人能审阅这段代码,我将不胜感激。

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

string replace(string input);

int main(int argc, string argv[])
{
    if (argc != 2)
    {
        printf("Usage: ./no-vowels word\n");
        return 1;
    }

    printf("%s\n", replace(argv[1]));
}
// line 22 is here which shows the error message
string replace(string input)
{
    int len = strlen(input);

    for (int i = 0; i < len; i++)
    {
        switch (input[i])
        {
            case 'a':
                input[i] = 54;
                break;
            case 'e':
                input[i] = 51;
                break;
            case 'i':
                input[i] = 49;
                break;
            case 'o':
                input[i] = 48;
                break;
        }
    }

    return input;
}
c expression
© www.soinside.com 2019 - 2024. All rights reserved.