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
-1
votes
4 answers

How to get a single character in conjunction with using scanf (for non-characters or Strings) in a loop

This is my code: struct Patient{ char name[50]; char gender ; // M:male , F:female unsigned age ; unsigned Systole; unsigned Diastole; }; //blah blah blah struct Patient P[3]; for(i=0 ; i<3 ; i++){ printf("\nPATIENT%d\n",i+1); …
Alireza Mohamadi
  • 751
  • 1
  • 6
  • 22
-1
votes
1 answer

issue with converted char number to int using getch();

this function doesn't check the nums at the ifs... what i need to do? tnx for helping! //Includes #include #include #include //Defines #define FIVE 5 #define SIX 6 #define TEN 10 #define FIFHTY 15 #define…
Ruslan Ver
  • 127
  • 4
  • 12
-1
votes
2 answers

c++ Using _getch() for instant user input, but it keeps returning different numbers

int choiceOne = 0; choiceOne = _getch(); cout << choiceOne; _getch(); system("CLS"); I would like choiceOne to = what the user enters, but it outputs (48+ The user input) So if I enter 0 it will output 48, if I enter 5 it will output 53. I'm not…
Max Mcgregor
  • 101
  • 9
-1
votes
3 answers

What do I need to change to make this C programm work on Linux?

I need to make this work Linux, I know that conio.h is not for Linux and the main problem is getch() function. I tried using another lib like curses.h but still I got a lot of errors. It takes users input of password and converts it to **** for…
user3350179
-1
votes
2 answers

Compiler gives - warning C4013: 'getche' undefined; assuming extern returning int

I'm using Visual studio for my code development and when I used the function getche() The compiler gave me this warning warning C4013: 'getche' undefined; assuming extern returning int But the getche() function is working just as expected ,…
Sorcrer
  • 1,634
  • 1
  • 14
  • 27
-1
votes
1 answer

Python: Getch() not Recognized as a Defined Variable

I'm new to python and am having trouble with the getch.getch command. I am creating a program that will print a binary numpy array that the user inputted - without hitting enter. To do this, I created an array of zeros and a list of letters with…
-1
votes
2 answers

Read input without using conio.h library

First, I've read some references and googled it. But I can't find any way to read input without pressing enter by not using getch(). while getchar() cin>> and getline() need enter to read the input. I'm practicing doing questions with online judges…
user3411184
  • 71
  • 1
  • 10
-1
votes
1 answer

Changing the value of a variable from getch()

Update: I've added the parentheses and byte however the code still doesn't change the output. I'm trying to write a python program that sees what the user is typing using getch() and then changes it (and prints the changed version) - so if the user…
Ollie
  • 21
  • 4
-1
votes
1 answer

Difference between getch() and scanf() functions

I had difficulties while executing the following code. The variable 't' take a null value after complete one execution. The problem was solved by using getch() instead of scanf(). But i don't know why it's happening. Any explainations ? This is the…
devKeshav
  • 41
  • 1
  • 5
-1
votes
1 answer

eclipse C++ alternative for getch()

I am using C++ under Eclipse. With the Borland compiler I have used getch() function to take user input without showing what was entered. The getch() function is not working under Eclipse. Is there another way to get the user input without…
gotqn
  • 42,737
  • 46
  • 157
  • 243
-2
votes
1 answer

Defining getch() function in c/c++

Why when I use getch() function in c++, I should include "conio.h" header file ... while in c it runs without include this file? I'm using codeBlocks as my IDE. I expect that I must include "conio.h" in c program also, and I tried to include…
-2
votes
1 answer

How to avoid problem with function getch()

I've got a problem with my program. It's kind of looped menu. I write in VS Code. The problem is when I run program and try to choose one of the three options it runs option after else: print("No more option"). The code below: from getch import…
Maria
  • 117
  • 9
-2
votes
1 answer

getch() doesnt produce the expected result

I am on ncurses.I am working on a program that starts a timer when I press enter. I use this code: while(( ch = wgetch(w)) != 'q' ) { switch( ch ) { ... case ENTER: /*timer is expected to start…
Hakan Demir
  • 307
  • 2
  • 4
  • 12
-2
votes
1 answer

Segmentation fault when getch() is called

Got this issue on termux (Android Linux terminal emulator) . Here it is the ENTIRE code: #include int main() { initscr(); getch(); endwin(); } I then compiled using this line: g++ -lncurses prog.cpp The package is…
-2
votes
1 answer

Segmentation fault while calling getch()

I am trying to make a simple console program using curses on ubuntu, but each time I try to call getch and make it wait for input, when I input the input, it throws a segmentation fault. I did initialize the library using the initscr() function in…
mindoo
  • 1
  • 6
1 2 3
19
20