I am working on a program and I have to send one char at a time through a socket. The connection work fine and the chars are sending but when I have to print them to stdout, I cant manage to print them without a newline.
for ( ; ; ) {
nb = select(connfd+1, &read_set, NULL, NULL, NULL);
if (nb<=0) {
printf("Error\n");
}else{
if (FD_ISSET(connfd, &read_set)) {
char buff[2];
nb = read(connfd, buff, 4096);
if (nb < 0){
printf("The client disconected\n");
break;
}
printf("%s\n",buff); // this prints them with a new line between each char.Removing the \n will make it work only by hitting enter
//fputs(buff,stdout); //does the same as printf without \n
}
One more mention: the client send chars without waiting for ENTER from stdin.
Any hints? Thanks