Below I would like to enter the characters "s1p1" into a remote terminal once the server has connected to the client and print the respective statement locally. The problem I am having when I want to write "s1p1" is that if i press s, the program processes s, but when I press "1" the program no longer has the s stored.
The program performs actions to single characters successfully as shown by the second enclosed if statement.
Any suggestions?Code:int sock_fd; int new_fd; int rc; char recv_client_msg[100]; rc=read(new_fd, recv_client_msg,sizeof(recv_client_msg)); if(rc>0) { if(strcmp(recv_client_msg,"s1p1")==0){printf("s1p1\n");} if(recv_client_msg[0]=="s"){printf("m\n");} }
I assume the solution will involve somewhere an array and a for loop with incrementation.
Before anyone suggests changing "strcmp" this is NOT the issue and the issure is storing the characters without overwriting them.
Any help would be appreciated.