Skip navigation.
Home

Removing newline character from user input

Question:

Is there any way to remove the new line character from user input?

Answer:

printf("Do you want to play again (y/n) ");
// don't put \n at the end of the above question.
n=getline(&buffer, &nbytes, stdin);
buffer[1] = '\0'; // get rid of '\n'