c - 为什么我的代码中会出现此括号错误?

标签 c

所以,我在第 83:9 行或斜杠所在的位置遇到括号问题。它告诉我“错误:预期标识符或‘{’ token 之前的‘(’”,我不明白我是如何收到此错误的。如果有人可以向我解释我是如何收到它的,谢谢。

不多

_Bool palindromes(char string[])
    {
    int i = 0;
    while(string[i]=0 != '\0')
            {
            i++;
            int last_place = i - 1;
                    for(int n=0; n<=last_place; n++)
                    {
                    if(string[n] == string[last_place])
                    {
                    last_place--;
                    continue;
                    }

                    if(n !=last_place)
                    {
                    return false;
                    }

                    }
            }
    }


    { //here is the bracket it's detecting
    int i = 0;
    while(string[i]=0 != '\0')
            {
            i++;
            int last_place = i - 1;
                    for(int n=0; n<=last_place; n++)
                    {
                    if(string[n] == string[last_place])
                    {
                    return true;
                    }
                    }


             }
    }

最佳答案

如果您修复了您的身份

_Bool palindromes(char string[])
{
    int i = 0;
    while(string[i]=0 != '\0')
    {
        i++;
        int last_place = i - 1;
        for(int n=0; n<=last_place; n++)
        {
            if(string[n] == string[last_place])
            {
                last_place--;
                continue;
            }
            if(n !=last_place)
            {
                return false;
            }
        }
    }
}   <---------- ups, function ends here


{ //here is the bracket it's detecting
    int i = 0;
    while(string[i]=0 != '\0')

这清楚地表明您的 } 太多了

关于c - 为什么我的代码中会出现此括号错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58777225/

相关文章:

c - 如何在 C 中处理未知类型的数字?

c - 称为 PRUNING 的图像处理技术

Char 和 Int 打印两个不同的值

c - 使用 C 中的函数和指针将 n 个数组合并为一个

c - 使用 getchar() 是/否用户提示

java - 堆栈由编译器或操作系统/架构创建

c - 取一个数字并输出其英文单词的算法

c - 结构数组错误

c - 前向声明结构体的范围

c: valgrind "Conditional jump or move depends on uninitialised value(s)"