Thread: 20q game problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    26
    Nevermind ive done it now.

    What i did was make a new function..............

    Code:
    int quitGame()
    {
    	int quit = 0;
    	char buffer[ BUFFER_SIZE ];
    	
    	if ( strcmp ( buffer, EXIT_KEY ) )
    	{
    		quit++;
    	}
    	
    	return quit;
    }
    Then i added this to the main function..........

    Code:
    	if ( quitGame() == 1 )
    	{
    		printf ("\nThank you for playing!");
    		
    		continue_game = 0;
    	}
    Now all this has led to a new problem, now when i start the program any key i press quits the game. Any ideas on how to stop this from happening?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    However, quitgame just compares some random data held in "buffer" to the EXIT_KEY value. Highly unlikely to ever become true (random in this case isn't random in the sense that it's a good source for random numbers, but rather random in the sense that it is not known, and will vary depending on a number of different circumstances - but it's highly likely to never be EXIT_KEY).

    Code:
    quit++;
    Perhaps you'd like to say
    Code:
    quit = 1;

    Also, strcmp returns 0 for a match, and other numbers for non-equal result, so it's very likely that you ALWAYS return 1 from this function.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. craps game & dice game..
    By cgurl05 in forum C Programming
    Replies: 3
    Last Post: 03-25-2006, 07:58 PM
  3. Game Problems
    By Spectrum48k in forum Tech Board
    Replies: 4
    Last Post: 06-02-2004, 07:08 PM
  4. Game Programmer's AIM Circle: Join Today
    By KingZoolerius66 in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 12-20-2003, 12:12 PM
  5. Someone help me with this game??
    By stehigs321 in forum Game Programming
    Replies: 15
    Last Post: 10-30-2003, 09:42 PM