Skip to content

Instantly share code, notes, and snippets.

@neuro-sys
Last active December 12, 2015 05:38
Show Gist options
  • Select an option

  • Save neuro-sys/4723039 to your computer and use it in GitHub Desktop.

Select an option

Save neuro-sys/4723039 to your computer and use it in GitHub Desktop.
Windows console api
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
char array[255];
HANDLE h_out, h_in;
AllocConsole();
h_out = GetStdHandle(STD_OUTPUT_HANDLE);
h_in = GetStdHandle(STD_INPUT_HANDLE);
SetConsoleTextAttribute(h_out, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY | BACKGROUND_BLUE);
SetConsoleMode(h_in, !(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT));
while(1) {
COORD coord;
coord.X = rand()%70;
coord.Y = rand()%25;
sprintf(array, "%c", rand()%25+'a');
WriteConsoleOutputCharacter(h_out, array, 1, coord, NULL);
}
//ReadConsole(h_in, array, 1, NULL, NULL);
return 0;
}
#if 1
void WinMainCRTStartup()
{
WinMain(NULL, NULL, NULL, 0);
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment