🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.os.linux.programowanie
Article #60201

Re: jak odczyta? dane wpisane z klawiatury aby nie by?o "echa" ?

#60201
From: Robert Jaroszuk
Date: Tue, 25 Oct 2005 16:13
53 lines
2601 bytes
On Tue, 25 Oct 2005, Rafa? wrote:

> mam pytanko do grupowiczow:
> jaka funkcja albo sposobem odczytac dane wpisywane z klawiatury
> aby nie pojawialy sie znaki na ekranie
> w trybie tekstowym oczywiscie

Bylo na grupie juz pierdyliard razy.
Srednio raz na dwa miesiace od kilku lat ktos o to pyta.
Archiwum nie dziala?

#include <stdio.h>
#include <termios.h>

char getch(void) {
  char buf = 0;
  struct termios old = {0};
  if (tcgetattr(0, &old) < 0)
     perror("tcsetattr()");
  old.c_lflag &= ~ICANON;
  old.c_lflag &= ~ECHO;
  old.c_cc[VMIN] = 1;
  old.c_cc[VTIME] = 0;
  if (tcsetattr(0, TCSANOW, &old) < 0)
     perror("tcsetattr ICANON");
  if (read(0, &buf, 1) < 0)
     perror ("read()");
  old.c_lflag |= ICANON;
  old.c_lflag |= ECHO;
  if (tcsetattr(0, TCSADRAIN, &old) < 0)
     perror ("tcsetattr ~ICANON");
  return (buf);
}

int main() {
  char key;
  printf("Press 'x' to exit...\n");
  while((key=getch()) && (key != 'x'))
    printf ("wcisnales %c, masz wcisnac 'x'\n", key);
  return(0);
}



-- 
... Robert Jaroszuk ...
GCS/IT/O d? s: a-- C++ ULB++++$ P+ L++++$ E--- W- K- N+ DI+ V-
w M- PS+ PE Y(+) PGP-(+++) t-- 5? X- R tv-- b++>++++ D- y+ G++
.. http://zim.iq.pl/ . RJ735-RIPE . http://zim.iq.pl/photo/ ..
... The superior warrior wins without fighting -- Sun Tzu. ...

-- 
Archiwum grupy: http://niusy.onet.pl/pl.comp.os.linux.programowanie
Technical Details
Message-ID: <20051025161327.GA29086@iq.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!newsfeed.silweb.pl!news.onet.pl!newsgate.onet.pl!newsgate.pl
References: <djl5if$nff$1@atlantis.news.tpi.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!newsfeed.silweb.pl!news.onet.pl!newsgate.onet.pl!newsgate.pl
From: zim@nospam.iq.pl (Robert Jaroszuk)
Newsgroups: pl.comp.os.linux.programowanie
Subject: Re: jak odczyta? dane wpisane z klawiatury aby nie by?o "echa" ?
Date: 25 Oct 2005 18:13:52 +0200
Organization: email<>news gateway
Lines: 54
Message-ID: <20051025161327.GA29086@iq.pl>
References: <djl5if$nff$1@atlantis.news.tpi.pl>
NNTP-Posting-Host: newsgate.onet.pl
Mime-Version: 1.0
X-Trace: newsgate.test.onet.pl 1130256832 7777 213.180.130.18 (25 Oct 2005 16:13:52 GMT)
X-Complaints-To: abuse@onet.pl
NNTP-Posting-Date: 25 Oct 2005 16:13:52 GMT
X-Received: (root@newsgate.test.onet.pl) by newsgate.test.onet.pl id <S115160AbVJYQNl>; Tue, 25 Oct 2005 18:13:41 +0200
X-Received: from smtp-out-io.iq.pl ([213.76.165.134]:49569 "EHLO io.iq.pl") by newsgate.test.onet.pl with ESMTP id <S115181AbVJYQN2>; Tue, 25 Oct 2005 18:13:28 +0200
X-Received: by io.iq.pl (Postfix, from userid 1000) id 3D2B7BB3E; Tue, 25 Oct 2005 18:13:27 +0200 (CEST)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit