[Solved] Do-while acting funny in my basic singly linked list implementation in C. Please identify the error [closed]


When you enter anything for input with Scanf, you end it with a newline. The problem is that the scanf function only extracts the input requested, and leaves the newline in the input buffer, so in the next iteration the program reads and extracts that newline and sees it as invalid input and loops once again.

This is very easy to solve: Add an extra space before the "%c" format code, so it’s

scanf(" %c",&choice);
/*     ^           */
/*     |           */
/* Note space here */

This will tell scanf to read and discard all leading white-space (which newline is).

I also recommend you to read e.g this scanf reference.

0

solved Do-while acting funny in my basic singly linked list implementation in C. Please identify the error [closed]