Removing newline character from user input
Submitted by tuanpham on Wed, 08/05/2009 - 17:35
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'
»
- Login to post comments
