answersLogoWhite

0


Best Answer

Pick one:

1. Consult ncurses' manual, especially getch.
2. Consult termios' manual, especially cfmakeraw.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you get a single character from the keyboard in Linux using C?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Is a wildcard for more than one character?

It depends on where you are using it. Back in the DOS days, a * meant multiple characters and a ? meant one character. I've seen software that says to use *, ?, and % for wildcards, but they were all for multiple characters. So it really depends on what you are using. Not everything supports a single wildcard.


What is the return value of getch?

getch(); is used for unbuffered input. e.x: int main() { char num=0; printf("Press a keyboard button: "); num = getch(); //This brings in 1 character that the user pressed on the keyboard printf("\nYou pressed: %c", num); //This prints the character you pressed getchar(); // I am using getchar(); to stop the program from ending after pressing buttons return 0; } My input will be within the (). output: Press a keyboard button: (v) You pressed: v EOP //End of program I hope this has helped you!


The worksheet space is where data is typed and organized using what?

usually, the keyboard.


How get input form keyboard?

Retrieving keyboard input depends partly upon whether you're writing a console or graphical application. If you're writing a console application, you have the following functions available: - sscanf() in the stdio.h header - getchar() in the stdio.h header - getch() in conio.h and curses.h (plus kbhit() if it's available) For Win32 applications, which are event-driven, you'll want to intercept the WM_CHAR event that's passed to your window handler (WndProc). The wParam parameter will contain the character on the keyboard that's pressed. For other APIs, you'll want to check the documentation, or look on the Web for tutorials describing how to get keyboard input using whichever API you're using.


Can you replace getch of C programming in Linux without using iostream header?

There is a 'getch' in 'conio.h' which has nothing to do with 'iostream'.

Related questions

I'm using ubuntu 8.04.1 and when you try pushing esc at the grub prompt to change your password it continue and loads up what do you do?

This is usually caused by using a USB keyboard. The BIOS knows how to use a USB keyboard, and so does Linux. But GRUB can only recognize keyboard inputs from older types of keyboards, like the type that plugs into a PS/2 port. All you need to do is enter your BIOS and enable "Legacy USB" or "USB keyboard emulation." This will allow the keyboard to be used during the initial booting phase, before Linux starts.


Why does Linux take forever to reboot?

I find that my four computers using Linux (Ubuntu, Mint) are much quicker to reboot than my wife's single Windows 7 computer.


How do you recover a Linux drive?

That depends very much on what happened to it, the file system it was using, and the platform you are using. As such, there is no single or comprehensive set of instructions that can be applied to such a broad question.


What the definition for keyboard?

Using a keyboard.


How do you delete a file using keyboard?

how to delete a file using keyboard


What is the word 2010 feature for using keyboard combinations instead of the mouse to select character formatting commands called?

Shortcut keys


Can you run a small business using Linux on your PC?

Yes, a small business can be run using Linux. Two popular operating systems are Ubuntu or Linux Mint.


What are the advantages of using a Linux dedicated server?

The advantages of using a Linux dedicated server are access to more scripting languages and Linux is an open-source free software (costs less to make a Linux server).


What platform does Testking use?

The platform used by the Testking website is Linux. It has been using Linux for about one year now. Prior to using Linux, it ran on windows. Linux is a popular platform for many websites.


Is Android Using Linux?

Yes android is based off of the Linux Kernel.


Where is the trademark key on the standard keyboard?

There isn't one. How you input a character like this will depend upon the word processing (or similar) program you are using.


What is the special character used to match any single character in a search string?

If you're using regular expressions, the character commonly used is a dot '.'. This will match any character except a newline. To match all characters including newlines would involve a statement, not a single character.