In windows, you can use the header `<conio.h>` which has a function called `getch()` for getting a char directly from the console.
Example:
#include<stdio.h>
#include<conio.h>
main()
{
printf("Waiting for a character to be pressed from the keyboard to exit.\n");
getch();
return 0;
}Example for Dev C++ compiler:
#include<stdio.h>
main()
{
printf("Waiting for a character to be pressed from the keyboard to exit.\n");
getchar();
return 0;
}In Linux you can download `<ncurses.h>` library and then you can use `getch()`.
Comments