When I'm using getch() in my program, I get this odd character that appears to be sent to stdin. This character is (B
. Here's my code:
#include "structures.h"
#include "functions.h"
char choice;
int option;
char *ptr;
int main(void) {
while(1) {
puts("============================================Select an Option============================================");
puts("1. Create Linked List");
puts("2. Display items");
puts("3. Add item to the beginning");
puts("4. Add item to the end");
puts("5. Add item in the middle");
puts("6. Delete item from the beginning");
puts("7. Delete item from the end");
puts("8. Delete item from the middle");
puts("9. Exit");
printf(">>> ");
initscr();
choice = getch();
option = choice - '0'
switch (option) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
puts("\033[0;32mExiting...\033[0m");
return 0;
default:
handle_error("Invalid option. Please enter a number between 1-9");
continue;
}
break;
}
endwin();
return 0;
}
I'm not going to include the header files I created since they don't have anything to do with this. Does anyone know how to fix this?