Thread: One Error

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    7

    One Error

    OK so here is the code and the only problem it says is there is wrong syntax for the input in the main function.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    //Second option for all if statements are not working unless they redirect to another class.//
    void KingAlbertsArmy(){
         printf("You enlisted in the King's army at age 16.\n");
    }
    void Rebels(){
         printf("You are constantly moving around from village to village\n gathering as many people as you can to fight the king.\n");
    }
    void Martyr(){
         printf("Living your early childhood years as a choirboy you eventually became the father of the church.\n");
    }
    void Chapter1(){
         int allianceselection;
         int kingalbertsarmy = 1;
         int rebels = 2;
         int martyr = 3;
         printf("King Albert has an army that is killing everyone that oppose and do not worship him.\n");
         printf("Which side will you fight for; enlist in the King's Army or fight with the Rebels for freedom.\n");
         printf("..or fight for your beliefs as a Martyr.\n");
         printf("Who will you fight for.\n");
         printf("1. King Albert's Army.\n");
         printf("2. Rebels.\n");
         printf("3. Martyr.\n");
         scanf("%d", &allianceselection);
         if(allianceselection == kingalbertsarmy){
                              KingAlbertsArmy();
                              }
         else if(allianceselection == rebels){
              Rebels();
              }
         else if(allianceselection == martyr){
              Martyr();
              }
         }
    void Backstory(){
         printf("You choose to receive backstory...well there isn't much of that at all.\n");
         printf("The little backstory that is available is that King Albert is on a vicious rampage,\n");
         printf(" killing all that oppose or do not worship him.\n");
         Chapter1();
    void StartingOut(){
         int backstoryselection;
         int yes = 1;
         int no = 2;
         printf("Would you like backstory?\n");
         printf("1. Yes.\n");
         printf("2. No.\n");
         scanf("%d", &backstoryselection);
         if(backstoryselection == yes){
                               Backstory();
                               }
         else if(backstoryselection == no){
                                    Chapter1();
                                    }
    }
    void Exit(){
         printf(" Now Closing\n ");
         }
    void Multiplayer() {
         printf(" Loading Multiplayer Option\n ");
         printf(" Multiplayer Option isn't available at the moment.\n");
         }
    void Play() {
         printf(" Play\n ");
         StartingOut();
         }
    void Load() {
         int loadnot;
         int loadnotnewgameyes = 1;
         int loadnotexityes = 2;
         printf(" Load\n ");
         printf(" Must have a saved game to load.\n");
         printf(" Would you like to start a new game or exit?\n");
         printf(" 1. Start New Game.\n");
         printf(" 2. Exit.\n");
         scanf("%d", &loadnot);
         if(loadnot == loadnotnewgameyes){
                    Play();
                    }
         else if(loadnot == loadnotexityes){
              Exit();
              }
         }
    void MainMenu() {
         int gameselectioninput;
         int playgame = 1;
         int loadgame = 2;
         int loadmultiplayeroption = 3;
         int exit = 4;
         printf("     Created By: Anthony Brown.     \n");
         printf("                                    \n");
         printf("             Ravages                \n");
         printf("1. Play Game\n");
         printf("2. Load Game\n");
         printf("3. Load Multiplayer Option\n");
         printf("4. Exit\n");
         printf(" Enter Selection Number \n");
         scanf("%d", &gameselectioninput);
         if( gameselectioninput == playgame){
             Play();
             }
         else if ( gameselectioninput == loadgame){
              Load();
              }
         else if ( gameselectioninput == loadmultiplayeroption){
              Multiplayer();
              }
         else if ( gameselectioninput == exit){
              Exit();
              }
         }
    int main()
    {
        MainMenu();
        getchar();
        return 0;
    }
    I don't know what's wrong with it. Please help me.

  2. #2
    Registered User
    Join Date
    Apr 2012
    Posts
    7
    Never mind I figured it out. Thanks anyways. I don't know how to delete posts so that is why I didn't.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    > I don't know how to delete posts so that is why I didn't.
    You shouldn't delete posts after a topic is solved. Why do you think this forum is public?

    Also, your method of comparing user input is ridiculous. Learn how to use #define'd constants instead of making four unnecessary ints.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-28-2011, 11:48 AM
  2. Replies: 4
    Last Post: 07-24-2011, 09:38 PM
  3. Replies: 1
    Last Post: 11-15-2010, 11:14 AM
  4. Replies: 3
    Last Post: 10-02-2007, 09:12 PM
  5. Replies: 1
    Last Post: 01-11-2007, 05:22 PM