Why strcmp function is not comparing the received command from the user with LIST ( without strcmp the function is working )
问题 I am new to socket programming, I am writing an FTP server without the client I have to access the server using netcat localhost port void do_job(int fd) { i,client; char command[DEFAULT_BUFLEN]; while((client =recv(fd, command, strlen(command), 0)) >0 ) { if (strcmp(command,"LIST") ==0) { } in the main function : if ((pid=fork()) == 0) { close(listenfd); do_job(fd); printf("Child finished their job!\n"); close(fd); exit(0); } 回答1: You need to add a null terminator to the string in order to