You don’t handle the newline. The %c
specifier doesn’t skip blanks. Try:
scanf(" %c", &newChar);
/* ^ <-- Makes `scanf` eat the newline. */
Or maybe add an explicit test.
scanf(...);
if (newChar == '\n')
continue;
More Related Contents:
- Assorting linked list in c [duplicate]
- Why my Program isnt working after providing input?
- Debugging a linked-list
- Please help me out, i want to display the linked list, reverse it & display then again display it
- Disadvantages of scanf
- How to avoid pressing Enter with getchar() for reading a single character only?
- C non-blocking keyboard input
- What is EOF in the C programming language?
- How to reverse a singly linked list using only two pointers?
- Check if input is integer type in C
- strcmp on a line read with fgets
- Reading string from input with space character? [duplicate]
- While (( c = getc(file)) != EOF) loop won’t stop executing
- Using pointers to remove item from singly-linked list
- read comma-separated input with `scanf()`
- How to use redirection in C for file input
- Rationale behind the container_of macro in linux/list.h
- How can I scan strings with spaces in them using scanf()? [duplicate]
- Deleting a middle node from a single linked list when pointer to the previous node is not available
- Linked list recursive reverse
- C getopt multiple value
- Trouble reading a line using fscanf()
- strstr not functioning
- Finding the intersecting node from two intersecting linked lists
- Merging two sorted linked lists
- whitespace in the format string (scanf)
- C command-line password input
- C: How to free nodes in the linked list?
- How to implement a linked list in C?
- Why doesn’t pressing enter return ‘\n’ to getch()?