home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / rec / games / programm / 5214 < prev    next >
Encoding:
Text File  |  1992-12-29  |  1.3 KB  |  39 lines

  1. Newsgroups: rec.games.programmer
  2. Path: sparky!uunet!psinntp!blkbox!collins
  3. From: collins@blkbox (Chad R. Collins)
  4. Subject: Re: Goto [variable] in C++ ?
  5. Organization: The Black Box, PO Box 591822 Houston, TX 77259-1822 
  6. Distribution: rec.games.programmer
  7. Date: Tue, 29 Dec 1992 04:03:59 GMT
  8. Message-ID: <1992Dec29.040359.28909@blkbox>
  9. References: <1992Dec28.144429.1427@jupiter.sun.csd.unb.ca>
  10. Lines: 27
  11.  
  12. kinsman@jupiter.sun.csd.unb.ca (Aphoriel/Kinsman) writes:
  13.  
  14. >This is a question from someone new to C...
  15.  
  16. >How could I set up C code so that a program goes to a function where the name
  17. >of the function is placed in a string variable? The specific use I'm thinking
  18. >of is for an adventure game, where the function the parser calls depends on
  19. >the verb the player used in typing in his command.. I could set it up as:
  20.  
  21. >-If verb_parsed is 'eat' then call eat_function
  22. >-If verb_parsed is 'give' then call give_function
  23.  
  24. >and so forth, but this is awful... How could I write it in C to look like:
  25.  
  26. >-Go to [verb_parsed + string_holding_parameter_characters]
  27.  
  28. >Like that.
  29.  
  30. >Thanks in advance,
  31. >-Sean Givan / Aphoriel/Kinsman
  32.  
  33.     Well, I don't know the specifics of what you are doing, but you might
  34. want to look into the switch/case statements....
  35.  
  36. Chad R. Collins
  37. collins@blkbox.com
  38.  
  39.