LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to get keyboard input from C in Linux (https://www.linuxquestions.org/questions/linux-software-2/how-to-get-keyboard-input-from-c-in-linux-78258/)

yanming 08-02-2003 03:11 AM

How to get keyboard input from C in Linux
 
I am develop a "counsol application" (command line environment).
I want to know how to get keyboard input from a C program.
(this means the user interactes with the program by typing into
the command line.)

This program is related to creating teaching material for high
school programing class. I want to avoid using advanced GUI IDE.
I plan to use the open source IDE Rhide. or just use gcc.

arunshivanandan 08-02-2003 03:36 AM

Well,if u know C,just do whatever u know(i mean ANSI C and POSIX C).Else try learning C.
Or did u mean some high funda things i was not able to follow??Then sorry,i cant help u.

Tesl 08-02-2003 08:44 AM

do you actually know C? these sorts of things are usually taught early on :)

whenever i program in C (not too often i must admit) i would do something as follows:

Code:

#include <iostream.h>

// Your other includes, main() function whatever

int Input;
cout << "Enter a number: ";
cin  >> Input;

then again, i had someone new to C complaining about that saying it should be #include <iostream> and using std::cout rather than just cout. Iv been doing Java mostly of late so not totally up to speed :)

EDIT - i dont know if your question is more about whether you can use the same code in Linux as you would when coding in windows, to bring the Dos prompt. Its normally exactly the same.

yanming 08-02-2003 12:03 PM

Yes, I fogot many things I learned years ago. Sorry.

Actually, I can use getchar(), read(), getc(stdin), or maybe
fscanf(stdin, ...).

The cin and cout are C++ stuff.

actsby 07-27-2007 01:51 AM

Send Data From Application to PS/2 Port
 
I have designed small circuit using PS/2 port for communication with PC. Its easy to send data from my circuit to application(the data is treated as normal keypress)

but I don't know, How to send data from application (using C language) to PS/2 keyboard port ?


All times are GMT -5. The time now is 05:38 PM.