Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-19-2004, 04:10 PM   #1
Registered: Dec 2002
Location: Portugal
Distribution: Fedora Core 5
Posts: 82

Rep: Reputation: 15
Some system calls

hi there!

I need to make a C function that reads from stdin using ioctl() read() gettimeofday() system call's to when some char apears on the screen it get's the exact time that i took to press the right key...
how can i do this?
Old 11-24-2004, 10:17 AM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Here is a start on your homework, this reads a single keypress:
#include <termios.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
int getch(void) {
      int c=0;

      struct termios org_opts, new_opts;
      int res=0;
          //-----  store old settings -----------
      res=tcgetattr(STDIN_FILENO, &org_opts);
          //---- set new terminal parms --------
      memcpy(&new_opts, &org_opts, sizeof(new_opts));
      new_opts.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ECHOPRT | ECHOKE | ICRNL);
      tcsetattr(STDIN_FILENO, TCSANOW, &new_opts);
          //------  restore old settings ---------
      res=tcsetattr(STDIN_FILENO, TCSANOW, &org_opts);


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unix system calls with c pengui Programming 13 07-29-2012 11:54 PM
shell example using system calls djgerbavore Programming 7 03-06-2010 02:39 AM
system calls in Java AMMullan Programming 2 04-14-2004 01:48 AM
System Calls file Hady Programming 1 12-13-2003 12:14 PM
java and system calls aizkorri Programming 6 06-20-2003 01:54 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:02 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration