Thread: I cant get it to open my shop()

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    I cant get it to open my shop()

    Im making a text based game and I was going to add in potions into my game. Instead of just adding in all the functions dealing with the potions, I wanted to make a small program that had just a shop() in it. In the shop(), you could buy a potion and it would take you to an addPotion(). But, even though it works in my main game, my smaller one wont open up the shop. And I cant seem to figure out why.

    This is the code to my main(), which runs a small intro(), and then a begin(). In the begin function you pick to create a character or quit. After doing the createChar(), it brings you back to main()(here u can pick Shop or quit). Then thats where you select the shop(). But instead of loading the shop(), it loads the main() again(where u can pick shop or quit)

    Code:
    int main(){
    
        srand(time(NULL));
        intro();
        Sleep(500);
                   while(strcmp(chr.name,"") == 0 ){
                   begin();
                   }
             while (1) {
             cout << "\n\n What do you want to do? \n\n";
             cout << "1. Shop\n";
             cout << "2. Quit\n\n";
             cin >> choice2;
             switch(choice2){
                    case 1:
                            void Shop();
                            break;
                    case 2:
                         exit(0);
                    default:
                            cout << "\n\n Wrong....\n\n";
                    }
             }
    }
    Ive tried to write it as many ways as I know, but nothing seems to work. Can anyone tell me why?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Watch case sensitivity and post enough information to allow others to help you.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    2
    I posted that because I thought it was enough. Sorry if im new to this place as well. You could have at least asked for more information, instead of stating what you stated.

    Ill figure it out on my own.

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by DunDunDuh
    I posted that because I thought it was enough. Sorry if im new to this place as well. You could have at least asked for more information, instead of stating what you stated.

    Ill figure it out on my own.
    Buh-bye and happy coding!

    [aside]Can anyone compile what was posted? Does anyone know if multiple source files were used? Were there errors? Compiler or linker?

    Does anyone know what choice2 is... how it is declared?

    Is it just me, or did I lose my clairvoyance?[/aside]
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    hopefully, choice2 is an int.
    void Shop(); ...Can you do that there?

  6. #6
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    doesnt look to difficult ill give it a shot

  7. #7
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    umm which library is null under?

  8. #8
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    499
    Quote Originally Posted by lilhawk2892
    umm which library is null under?
    Try NULL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open Source Licenses
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-10-2006, 08:53 PM
  2. Big help in Astar search code...
    By alvifarooq in forum C++ Programming
    Replies: 6
    Last Post: 09-24-2004, 11:38 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Problems with open and save boxes
    By pinkcheese in forum Windows Programming
    Replies: 3
    Last Post: 05-21-2002, 06:03 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM