Skip to content

Instantly share code, notes, and snippets.

View rsmahmud's full-sized avatar

Rasel Mahmud rsmahmud

View GitHub Profile
@rsmahmud
rsmahmud / getch.c
Created March 17, 2017 20:15
getch() function from conio.h library implementation on Windows
#include <windows.h>
TCHAR getch(){
DWORD mode, cc;
HANDLE h = GetStdHandle( STD_INPUT_HANDLE );
if (h == NULL)
return 0; // console not found
GetConsoleMode( h, &mode );
SetConsoleMode( h, mode & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT) );
TCHAR c = 0;
ReadConsole( h, &c, 1, &cc, NULL );