C、 编译简单程序时出错

C、 编译简单程序时出错,c,gcc,C,Gcc,当我试图编译我非常简单的C游戏时,我遇到了一些问题 它说: “第125行错误:“return”之前的预期标识符或“(” 返回0;” 及 第126行错误:应为标识符或“}”标记之前的“(”号 }" (第125行和第126行是我代码中的最后两行) 你应该把返回值放在倒数第二个}之前,并去掉最后一个括号在这篇格式糟糕的文章中,你可以投票指出这一点;)这里有一个很大的提示:编译之前不要写那么多代码。学会写一小段代码,然后在继续之前测试它。 <#include <stdio.h>

当我试图编译我非常简单的C游戏时,我遇到了一些问题

它说:

“第125行错误:“return”之前的预期标识符或“(” 返回0;”

第126行错误:应为标识符或“}”标记之前的“(”号 }"

(第125行和第126行是我代码中的最后两行)


你应该把返回值放在倒数第二个
}
之前,并去掉最后一个括号

在这篇格式糟糕的文章中,你可以投票指出这一点;)这里有一个很大的提示:编译之前不要写那么多代码。学会写一小段代码,然后在继续之前测试它。
<#include <stdio.h>
    #include <time.h>
    #include <stdlib.h>



    int main (void)

    {

        int headbang,x,y,fx,fy;
        char choice;

        headbang = 0;



    {
     srand(1); 
     int fx = rand()%5 + 1; 
    }
     {
     srand(2); 
     int fy = rand()%5 + 1; 
    }
     {
     srand(3); 
     int x= rand()%5 + 1; 
     }
     {
     srand(4); 
     int y= rand()%5 + 1; 
     }


        printf ("It is pitch black. You have no idea how you got here, but you \nknow that you have to find some source of light in order to get \nout. \n \n");



        printf ("Where do you want to go? ");


        {
        scanf(" %c", &choice);


        switch (choice) 
    {
        case 'n':
    x++;

    printf ("You crawl North.\n");
    break;



        case 's':
    x--;

    printf("You crawl South \n");


        case 'e':

    y++;

    printf ("You crawl East.\n");
    break;

        case 'w':


    y--;

    printf ("You crawl West.\n");
    break;

    default:
    printf ("Sorry, you can only go north, south, east or west.");


    }
        if (x==0 || y==0 || x==6 || y==6)
    {
    printf("Ouch! You hit your head in the wall.");
    headbang++;

        if (x==0)
    {
    x++;
    }

        else if (y==0)
    {
    y++;
    }

        else if (x==6)
    {
    x--;
    }

        else if (y==6)
    {
    y--;
    }

    }

        if (headbang == 2)
    {
    printf ("You slip into a deep sleep, never to wake up again...");
    }

        if (x==fx && y==fy)
    {
    printf("You feel something on the floor. It is a flashlight! \n You wake up, finding yourself in your own bed. What a nightmare!");
    break;
    }


    while (!(x==fx && y==fy));  
    }
    }   
        return 0;
    }