Questions tagged [getch]

Questions relating to the use of the DOS getch() function

getch() is defined in <conio.h>, a header file used mostly by MS-DOS compilers to provide console input/output.

This function is provided on Microsoft platforms, but is not in the C standard library, nor in POSIX.

It is similar to the standard library getchar(), but disables terminal echo of the character that is returned.

299 questions
2
votes
2 answers

How do I clean input buffer before using getch()?

So, I am using GetAsyncKeyState() to see when some key is pressed. But, after using it I need to use getch(). But it seems that getch() gets whatever GetAsyncKeyState() got before again. That is the version of my simplified code: #include…
user3496846
  • 1,627
  • 3
  • 16
  • 28
2
votes
2 answers

C++ Game - Loop and KeyPress at the same time

I made something like a game, you move your character(black box) up and down and there is a wall with some blank in middle of it, that wall is at right side, its coming from right to left side and if you touch the wall game ends. I get keypresses in…
user3332706
2
votes
1 answer

Strange behaviour of getch()

I have a program like this: #include #include using namespace std; int main () { for (int i = 0; i < 10; i++) { cout << int (_getch ()) << endl; } _getch (); return 0; } If I press keys like digits,…
user2064000
2
votes
1 answer

python curses - .getch() in newwin not working

I am attempting to make menu system using the curses module. I have the following code: import sys, os, traceback, curses def main(scrn): screen = scrn screen.border(0) curses.start_color() …
SheerSt
  • 3,229
  • 7
  • 25
  • 34
2
votes
2 answers

Why getch() is not working in Visual Studio 2008?

Below code works in DevC++ with MinGW works flawlessly but Visual Studio 2008 spits this: error C3861: 'getch': identifier not found . What can I do to accept getch() if this is not possible is there an alternative to getch() that I can use to…
Lyrk
  • 1,936
  • 4
  • 26
  • 48
2
votes
1 answer

_getch() doesn't work on windows server 2012

I need a DLL for users can type password and not echo on the screen. So I use _getch() for getting chars with no echo like this, //get character with no echo ch = _getch(); and compile the code use microsoft vs2005. It works on…
jmuok
  • 340
  • 1
  • 11
2
votes
2 answers

How to wrap a windows interactive console program for automation

I have an interactive console program in windows. I need to press keystroke like 'e' 'c' to the cmd window. It's convenient for human operating , but very difficult for program automation. And now, I would like to wrap the console program, in order…
scateu
  • 21
  • 3
2
votes
2 answers

getch and putchar not working without return

I have been trying to get getch to work in another program with no success. So I have made the most basic program I can using getch the way I want it to work in the main program. I have researched the need for noecho, cbreak, initscr and nodelay, I…
UNECS
  • 533
  • 1
  • 9
  • 20
1
vote
1 answer

Check for extra characters in Linux terminal buffer

I try to implement getch() function in Python, which should also return list of chars for special keys like F1-F12 and arrow keys. These special keys generate several chars in a sequence. Therefore getch() reads one char in blocking mode and then…
anatoly techtonik
  • 19,847
  • 9
  • 124
  • 140
1
vote
0 answers

How to hide a certain charcater or item in a map based on a dictionary in the cli

So i'm trying to have a item in a "map" that is only shown while within one tile and my current solution is not working. The location of the item-crafter (the function of which don't currently need support in) is set with these: scitemcraft =…
Blorpal
  • 19
  • 5
1
vote
1 answer

Only detects the first element of the array when it's compared with the input. I've tried with a lot of things and it's doesn't work out

It was supposed to be a function that detects when it's a vowel. But, it didn't work out as expected #include #include // It didn't work out. It failed // It was supposed to be a function that detects when it's a vowel. // But,…
migurd
  • 9
  • 3
1
vote
1 answer

How do you clear the buffer of getch() with ncurses

I have something like this: keypad(stdscr, TRUE); nodelay(stdscr, TRUE); char key; while(1) { usleep(80000); // ...Program related code... // Key Listener key = getch(); switch (key) { case 'a': // a…
Kalcifer
  • 1,211
  • 12
  • 18
1
vote
1 answer

Program is getting crashed when using getch and getche

#include #include #define max 100 void compare(char *name,char* input); int main() { int i=0; char name[max]="santosh"; char input[max]; printf("enter the password\n"); while((input[i]=getchar())!='\n'){ …
1
vote
0 answers

Why is getch() in C++ waiting for pressing Enter in CLion?

In CLion getch() is waiting for pressing of Enter button in this code #include #include using namespace std; int main() { char c = getch(); cout << c; } How can I fix it?
Max Popov
  • 357
  • 2
  • 12
1
vote
1 answer

Undo/ Redo Implementation using Stack

I want to implement Undo-Redo functionality using stacks. When the user presses Ctrl+Z the last node will be removed from the screen. When the user press again Ctrl+Z then the "last.last" node will be removed from the screen and if he presses Ctrl+Y…
Asad Sheikh
  • 61
  • 1
  • 8