compiler-errors - 继续获取 “error: expected identifier or ' (' ”,但我不明白为什么

标签 compiler-errors

每次编译时,我都会不断看到此消息。我想念什么吗?我已经检查了好几次了,这似乎是正确的。错误中特别提到的那一行是在声明了main函数之后。

// Caesar Cipher Program

int main(int argc, string argv[]); //need to check that argv[1] is not a float
{
    for (argc == 2 && int key = atoi(argv[1]) && key > 0) // Check that argv[0] is the file name as well? converts "key" (string) into int value
    {
        string text = get_string("plaintext: ");// Prompts user for plaintext

        printf("ciphertext: ");// Prints ciphertext

        for (int i = 0, n = strlen(text); i < n; i++)// Example of good design bc doesn't have to check the length of the string on every iteration
            {
                if (isalpha(text[i]) == true && isupper(text[i]) == true)
                    {
                        int j = 'text[i]' % 65;
                        int k = (j + key) % 26;
                        printf('65 + k');
                    }
                else if (isalpha(text[i]) == true && islower(text[i]) == true)
                    {
                        int l = 'text[i]' % 97;
                        int m = (l + key) % 26;
                        printf('97 + m');
                    }
                else
                    printf(text[i]);
            }

        return 1;
    }

    default
    printf("Try again.");
    return 0;

}

最佳答案

我只是发现了错误如果您看了看,您在顶部的主要功能不应以分号结尾:int main(int argc, string argv[]) ; //need to check that argv[1] is not a float而是:int main(int argc, string argv[]) //need to check that argv[1] is not a float如果您看到多余的分号。希望对您有所帮助,请告诉我是否可以。

关于compiler-errors - 继续获取 “error: expected identifier or ' (' ”,但我不明白为什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51449079/

相关文章:

编译器找不到已安装的库头文件

haskell - Haskell-同时打印并返回状态

java - 如何检测 Eclipse 编译错误(Java - JDT)

java - 需要澄清如何在 Java 中声明方法

c++ - 代码块错误

c++ - gcc 要求使用 -std=c++11 即使我已经在使用它

使用外部库引用编译 C 代码

C 函数 fopen();错误: too many arguments to the function

visual-studio - 构建 :Generic type 'Promise<T, R>' requires 2 type argument(s)

makefile - Snow Leopard 上 FFMpeg 的 libavformat 位于哪里?