Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Hi I have a do...while loop in C and I want it to stop only after a user has entered the character 'q' or 'Q' during the "Enter Command:- " section of the menu and send it through the switch case.
It will break the loop when the integer quit becomes a number other than 0 (a simple substitute for a boolean in C) which only happens during the 'q' or 'Q' case on the menu.
All other functions running off main work and do not bring up any errors as I have thoroughly tested them even with the broken menu.
However I think because of the scanf("%ch", &command); line the menu does extra unncessary loops until it takes in the character I originally entered because it doesn't ignore extraneuous characters when it should. Is there a character ignore method that I could use like there is in C++ to use on this menu?
int quit = 0;
node *head = (node*)malloc(sizeof(node));
node *cur = head;
**Word Editor Menu**
printf("(R) Move Cursor Right
printf("(L) Move Cursor Left
printf("(I) Insert character
printf("(D) Delete To Right of Cursor
Enter command:- ");
Enter character:- ");
quit = 1;
Not a valid command
0 · ·