Jump to content
  • Advertisement
Sign in to follow this  
rholding2001

delimiting a text string

This topic is 4985 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok my client at the moment sends and recieves messages. what i would like to do is apply a protocol that sends a ~ before a command and the start of a message. for eg to send a message in the client would look like this MSG~hello there - the msg means that im sending a msg to say the chat room. how do i go about doing this. thanks

Share this post


Link to post
Share on other sites
Advertisement
If you are using std::string, look up string::find_first_of(). It's a really useful function for string parsing.

If you are not, then a string is just an array of characters. To parse out the command just loop until you find the '~'. To get the data, continue the loop from where you left off with the command + 1. Loop until you reach the end of the string (e.g \0, \n, \r).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!