#include <stdio.h>
#include <stdlib.h>
main()
{
int Q = 1;
while(Q==1)
{
system("clear");
printf("MAIN MENU\n");
printf("--------------------------------------\n");
printf("1 - See all files\n");
printf("2 - See all files with permission\n");
printf("3 - VIM Editor\n");
printf("4 - EXIT\n");
fputs("Enter Choice : ",stdout);
char ch = getchar();
switch(ch)
{
case '1' : system("ls"); break;
case '2' : system("ls -l"); break;
case '3' : system("vi"); break;
case '4' : Q=0; break;
default : puts("Wrong Choice.."); break;
}
fflush(stdin);
fputs("PRESS ENTER TO CONTINUE...",stdout);
getchar();
}
}
The getchar() does not pause rather it just clears the screen and starts the menu again.
What is the cause of such problems? I am using tutorialspoint codingground online compiler.