Quote Originally Posted by Whilst View Post
how do i save to protocol[i++][20] the Components extracted/tokenized from tokenize()?
You could use strtok(). You should also declare tokenize() to return something, and you could use this return value to return the number of tokens extracted from the fromser buffer to the protocol[][] array. You would want to also pass the protocol array to tokenize, as well as how big the protocol array is (to prevent tokenize() from trying to add more to the array than it can handle). And with the InitialCards message, the directions say that it will send the "initialcards" token, the count token and then 13 cards, so protocol would need to hold at least 15 tokens but you have it declared to hold only 10.

The easiest way to use strtok() with your protocol array would be to change protocol from char protocol[10][20]; to char* protocol[MAX_TOKENS]; This would allow you to directly assign the result of strtok() to each element of protocol. Notice I did not put any numbers in the declaration either. You can #define MAX_TOKENS 15 (note no semi-colon) and then if you find you need more than 15 you can change this later. Then you can also use MAX_TOKENS anywhere you need to make sure you don't run off the end of the protocol array instead of using magic numbers.