I'm making a client-server program using sockets, and I need to client to be able to send a message to the server as a command, for example 'user 3' which connects the user to user 3. So far everything is working but I don't know how to separate the string into its useful parts. I need to first check the command which is 'user' and then check the second word which in this case is '3'.
So far I have only managed to split it using the '\0' delimiter which isn't proving to be all that useful, it only allows me to check is the user has said 'user' or '3'.
char receive[1024];
int read = recv(client_socket, &receive, 1024, 0);
receive[read] = '\0';
if (strcmp(receive, "user") == 0) {
printf("User has requested chat with....");
}