Skip to main content
gamedev.net
🔒 Locked

delimiting a text string

Started by rholding2001 0 replies 550+ views
Original Post
rholding2001
rholding2001
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
visit my site http://www.fullf1.com for all your formula 1 and music creation needs.
paradoxnj
paradoxnj
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).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.