View Single Post
  #4 (permalink)  
Old 12-26-2007, 09:11 PM
dargueta dargueta is offline
Guru
 
Join Date: Oct 2007
Age: 18
Posts: 695
Last Blog:
Programs Under the Hoo...
Credits: 353
Rep Power: 12
dargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the rough
Default

Try using a combination of scanf and strcmp. That way, you can use strcmp or whatever you want to run through a database and execute the appropriate action. For example:

C Code:
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <memory.h>
  4. #include <stdlib.h//only needed for system() in this program
  5.  
  6. void main(void)
  7. {
  8.     char nounBuffer[32];
  9.     char verbBuffer[32];
  10.  
  11.     while(strcmp(verbBuffer,"exit") != 0)
  12.     {
  13.         printf("What do you want to do? ");
  14.         scanf("%31s %31s",verbBuffer,nounBuffer);
  15.         //Here is where you need to compare the verb string to the
  16.         //verbs you can handle, like "eat" or "drink", etc.
  17.         //When you're done, continue here:
  18.  
  19.         //clear buffers
  20.         memset(nounBuffer,NULL,32);
  21.         memset(verbBuffer,NULL,32);
  22.         system("cls"); //clears the screen, remove if you want
  23.     }
  24. }
Reply With Quote