2011-04-05 110 views
0

嗨,我想使用微软视觉工作室2010年,使基于文本的游戏唯一的问题是,当我做了一些功能,它给了我这个错误,当我想运行它错误C2143:语法错误: ;”在'不变'之前,我无法弄清楚。这里是脚本,这是在C++错误C2143:语法错误:缺少 ';' 'constant'前

// 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; 
} 
+0

有时候,你得到这个错误,当你在一个以上的place.Ensure定义的全局变量你还没有它。 – Pramod 2011-11-16 12:12:20

回答

1

exit(0),不exit 0

你可能真的很容易地缩小了下来。还请大家下一次检查后的格式提交前:还有就是提问页面上的预览窗格。

相关问题