home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / rec / games / programm / 5220 < prev    next >
Encoding:
Internet Message Format  |  1992-12-29  |  1.2 KB

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