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
3
votes
3 answers

Strcat throws segmentation fault on simple getch-like password input

I am using Linux and there is a custom function of which returns an ASCII int of current key sort of like getch(). When trying to get used to it and how to store the password I came into an issue, my code is as follows: int main() { int c; …
John
  • 1,110
  • 3
  • 14
  • 28
3
votes
3 answers

Error pip installing getch Python3.5

I'm running Fedora 24. I want to import the getch module on Python 3.5.2 (which I think is already installed, however when I run python -V, it says Python 2.7.11) When I enter pip install getch I get this: Collecting getch Downloading…
JPYamamoto
  • 496
  • 6
  • 17
3
votes
1 answer

pip install getch : clang error

I am trying to install getch via pip and I have a clang error : python -m pip install getch Collecting getch Using cached getch-1.0.tar.gz Installing collected packages: getch Running setup.py install for getch ... error Complete output from…
tuttifolies
  • 1,417
  • 2
  • 14
  • 20
3
votes
2 answers

C++ — Arrow key press detection with getch() prints some words inexplicably

I have a simple program that can detect arrow key presses from the user, though I have two questions. But First, here's the code: #include #include #define KEY_UP 72 #define KEY_DOWN 80 #define KEY_LEFT 77 #define KEY_RIGHT…
Loqz
  • 373
  • 4
  • 16
3
votes
1 answer

hold screen for accepting arrow keys

for using arrow keys, first it has to be stored for analyzing it. That's why I am using scanf to store it. But when I try to run this code, and when I press up key, then it is showing ^[[A and when I press enter then this ^[[A removes and program…
piyush-balwani
  • 524
  • 3
  • 15
3
votes
2 answers

msvcrt.getch() returning b'a' instead of 'a'?

I have the following code from one class: class _Getch: def __init__(self): self.impl = _GetchWindows() def read_key(self): return self.impl() class _GetchWindows: def __init__(self): import msvcrt def…
Brynhildr Xie
  • 115
  • 1
  • 3
  • 10
3
votes
2 answers

How to run program whilst listening for user input in C?

I'm trying to make a game that continues running until a key is pressed and then it should take that key in and do something with it then continue running as per normal. How do I do this? I'm on MAC so even though I've come across a windows library…
Ikki
  • 33
  • 1
  • 5
3
votes
2 answers

Xcode Swift Command Line Tool reads 1 char from keyboard without echo or need to press return

I need a function, like the old "getch()", in Objective C or Swift to read one single character from the keyboard without echo and without the nedd to press return after the character has been typed to make the function continue. This is, I know,…
j.s.com
  • 1,422
  • 14
  • 24
3
votes
3 answers

difference in the usage of getch() and getchar() for clearing input buffer?

CODE 1:- char ch1, ch2; printf("Input the first character:"); scanf("%c", &ch1); while(getchar()!='\n'); printf("Input the second character:"); ch2 = getchar(); In this case while(getchar()!='\n');, clears the effect of enter-key pressed for…
kevin gomes
  • 1,775
  • 5
  • 22
  • 30
3
votes
1 answer

query regarding getch() input

CODE:- char ch,ch1; ch=getchar(); ch1=getch(); printf("%c\n%c",ch,ch1); When I enter a character during ch=getchar(), I have to press enter key, which remains in input buffer. That enter key is not read by the ch1=getch(). Why ch1=getch() is not…
kevin gomes
  • 1,775
  • 5
  • 22
  • 30
3
votes
1 answer

getch() returns wrong characters

I'm experiencing problems with the getch() function of the curses library. Suppose we have the following program: import curses def main(stdscr): while 1: c = stdscr.getch() stdscr.addstr(chr(c) + ": " + str(c) +…
chtenb
  • 14,924
  • 14
  • 78
  • 116
3
votes
1 answer

How to return a character from standard input on OS X in Python?

For a Python project that I'm working on I need to tell the user to insert a character and return its value in ASCII code without having to press enter to commit the key. It must also read the input only if my program is the active application,…
user2073384
3
votes
1 answer

'Inappropriate ioctl for device' error in C

I have a getch() function which my tutor gave me, which is getting input from the keyboard without clicking on 'ENTER'. But, when I run it in Ubuntu 12 in Eclipse, I get the following error: tcsetattr(): Inappropriate ioctl for device tcsetattr…
Jjang
  • 11,250
  • 11
  • 51
  • 87
3
votes
2 answers

curses getch() returns different values for the main window and pads in python

The getch() method returns different values for the main window and pads if the key pressed is non-ASCII. For example, pressing the arrow keys I get the expected KEY_UP, KEY_DOWN etc in the main window, but in the pad I get 65 for the up arrow and…
Bjorn
  • 1,090
  • 8
  • 12
2
votes
2 answers

Why is the value not changing when I change the number I assign?

I am working on a simple project using getch(). When I apply the variable 'door', it only sets to door1. if getch()==(' '): clicks+=1 money += door print("$ =", money, ((clicks-100)*-1), "clicks remaining", door, door1, door2, door3) if…
m11879
  • 23
  • 4