ошибка C2143: синтаксическая ошибка: отсутствует ';'перед "постоянным" - PullRequest
0 голосов
/ 05 апреля 2011

Привет, я пытаюсь использовать Microsoft Visual Studio 2010 для создания текстовой игры, единственная проблема заключается в том, что когда я выполнял некоторые функции, он выдавал эту ошибку, когда я хотел запустить ее. Ошибка C2143: синтаксическая ошибка: отсутствует ';'до «константы» я не могу понять это.вот скрипт это на с ++

// Text Game.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdlib.h>

void ShowIntroduction ( void )
{
    printf( "Hello welcome to this text-based adventure game.\n" );
    printf( "In this adventure game we will run into many difficult situations\n" );
    printf( "1. A situation will present it's self\n" );
    printf( "2. You will be given some choices.\n" );
    printf( "3. You will need to make some choices.\n" );
    printf( "4. The result of your choice will be shown.\n" );
}
void ShowSituation1 ( void )
{
    printf( "\n\nYou are walking down a loney, dusty road.\n" );
    printf( "When you see a gem on the ground.\n" );
    printf( "It is bright and shiny!!\n" );
}
void ShowSituation2 ( void )
{
    printf( "\n\nThe cave entrance looks inviting.\n" );
    printf( "You are tempted to enter.\n" );
    printf( "It looks kind of dark.\n" );
}
void ShowSituation3 ( void )
{
    printf( "\nDo you want to keep going?\n" );
}
void ShowChoices1 ( void )
{
    printf( "\nHere are your choices\n" );
    printf( "1. Pick up the gem.\n");
    printf( "2. Kick the gem off the road.\n" );
    printf( "3. Stomp on the gem.\n" );
}
void ShowChoices2 ( void )
{
    printf( "\nHere are your choices.\n" );
    printf( "1. Run away\n" );
    printf( "2. Take a nap.\n" );
    printf( "3. Slowly enter the cave.\n" );
}
void ShowChoices3 ( void )
{
    printf( "\n1. Ya I ain't scared.\n" );
    printf( "2. No I need my mommy.\n" );
}
int GetChoice ( int min, int max)
{
    int Choice;

    do
    {
    printf( "Your choice? " );
    scanf( "%d", &Choice );
    }
    while( Choice < min || Choice > max );

    return( Choice );
}
void ShowResults1 ( int Choice )
{
    if( Choice == 1 )
    {
        printf( "\nYou pick up the gem and put it in your backpack.\n" );
        printf( "You start walking down the road when you see smoke coming from your backpack.\n" );
        printf( "Quickly you throw your bag off and jump down the hill just in time to escape the explosin from your bag.\n" );
        printf( "You continue to roll down the hill, when you finally stop you get up and find a cave.\n" );
    }
    else if( Choice == 2 )
    {
        printf( "\nThe gem flys off the road.\n" );
        printf( "You decide to see if you can find where it landed.\n" );
        printf( "When you reach the bottom you notice a cave.\n" );

    }
    else if( Choice == 3 )
    {
        printf( "\nThe gem sends you sky high.\n" );
        printf( "You hope that your health insurance is up to date.\n" );
        printf( "Lucky for you it was a nice grassy hill you landed on.\n" );
        printf( "You stand up to figure out where you are.\n" );
        printf( "You notice a cave.\n" );
    }
    else
    {
        printf( "\nThat wasn't a Choice you bozo.\n" );
        printf( "You are dead now!!\n" );
        exit (0);
    }
}
void ShowResults2 ( int Choice )
{
    if( Choice == 1 )
    {
        printf( "\nWhat a chicken.\n" );
        printf( "Looks like you need your mommy.\n" );
    exit 0;
    }
    else if( Choice == 2 )
    {   
        printf( "\nIt is night time when you awake.\n" );
        printf( "You get up and start walking but don't make it far.\n" );
        printf( "You were attacked by a pack of wolves.\n" );
    exit 0;
    }
    else if( Choice == 3 )
    {
        printf( "You enter the cave slowly.\n" );
        printf( "Your only light sorce is a lighter in your pocket.\n" );
        printf( "You find a torch on the wall, you get the torch lit.\n" );
    }
    else
    {
        printf( "\nThat wasn't a Choice you bozo.\n" );
        printf( "You are dead now!!\n" );
        exit (0);
    }
}
void ShowResults3 ( int Choice )
{
    if( Choice == 1 )
    {
        printf( "\nYou decide to keep going.\n" );

    }
    else if( Choice == 2 )
    {
        printf( "\nWhat a pussy you are!!\n" );
    exit 0;
    }
    else
    {
        printf( "\nThat wasn't a Choice you bozo.\n" );
        printf( "You are dead now!!\n" );
        exit (0);
    }
}





int _tmain(int argc, _TCHAR* argv[])
{
    int Choice;

    ShowIntroduction ();

    ShowSituation1 ();

    ShowChoices1 ();

    Choice = GetChoice ( 1,3 );

    ShowResults1 ( Choice );

    ShowSituation2 ();

    ShowChoices2 ();

    Choice = GetChoice ( 1,3 );

    ShowResults2 ( Choice );

    ShowSituation3 ();

    ShowChoices3 ();

    Choice = GetChoice ( 1,3 );

    ShowResults3 ( Choice );

    return 0;
}

1 Ответ

1 голос
/ 05 апреля 2011

Это exit(0), а не exit 0.

Вы могли бы сузить это очень легко. Также, пожалуйста, в следующий раз проверьте формат вашего сообщения перед отправкой: на странице Задать вопрос есть панель предварительного просмотра.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...