   A text based adventure game
  Up to this point I''ve always focused on programming graphics but never got to making any gameplay.So I think it''s time that I get some experience with making good gameplay now, so I''d like to make a text based adventure game!!!There''s one little thingie though...  C++ strings and me don''t really like each other, C++ really lacks here, but I''d still like to do it with C++, so how do you even begin writing a good parser in C++?Thanks 
  Well, I suppose you''re talking about C++''s standard string class, and not char pointers.  If you are using char pointers, though, the string class really does make things a lot easier.  It has its quirks, though, main one that I hear about is that it tries to do too much.  Either way, using a string object, the find() method and the substr() method should be enough to search for spaces, or whatever other characters you wanted to search for, and substr returns small chunks of a string with ease.  And if you want to manually check every character for some reason, there''s always the at() method, as well as the overloaded [] operator. ;  If you appreciate ICBM-to-kill-a-fly solutions, take a look at the regex module of boost.Alan ;  This may be of use:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_string_manipulation.asp ;  you could always write your own string class too, if you really really really don''t like the standard ones. then you get to put in anything you like, and nothing extra. then overload some operators to make it easy to use. ;  Command parsing can grow into a huge undertaking, but here's a couple thoughts to get you started.First thing to do is split the command input into words.  This sample function will take a string and return the words as a vector: #include <string>#include <vector>vector<string> getWords(string input) {    string buffer = "";    const char* s = input.c_str();    vector<string> theVector;    while (*s != '\0') {   if (*s == ' ') {  // Found a space in the string.  Add the current  // buffer to the vector if the buffer is not empty  if (buffer != "") { theVector.push_back(buffer); // Clear the buffer to prepare for the next word buffer = "";  }   } else {  // Found a character in the string.  Add it to the buffer  buffer = buffer + *s;   }   s++;    }    // Reached end of input.  Check the buffer to see if there's    // still a word left to add    if (buffer != "") {   theVector.push_back(buffer);    }    return theVector;}  After you turn the input into a word vector, you can use the first member of the vector to determine which command function to call.  Example: void parseCommand(string input) {    vector<string> words = getWords(input);    // Exit the function if the word vector is empty    if (words.size() == 0) return;    // Find the command function to use according to the    // first word in the vector, and pass the words to it    if (words[0] == "go") {   doGo(words);    } else if (words[0] == "get") {   doGet(words);    } else if (words[0] == "drop") {   doDrop(words);    } else {   cout << "Command not understood." << endl;    }}  Then, in each command function, you can use the rest of the word vector to determine where the player wants to go, what he wants to get, or what he wants to drop.This is a very simple example.  See Richard Bartle's series of articles on parsers for an idea of how complicated they can get.(edit: changed tags from code to source) [edited by - DaTroof on February 4, 2004 12:11:55 AM];  Nice, thanks! 