[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C/C++ programming on Linux/Unix



On Sun, 7 Dec 1997, Stanislav Malyshev a.k.a. Frodo wrote:

> Re,
> > I have a big question.How can I get the functions like getch() and
> > getche() for Linux/Unix C programs ,or possibly to develop them by
> > any language (may be Assembler)?
> > Has anybody have an answer or solution?
> You may want to use curses library, or slang library. Or if you need
> only per-character input quick-and-dirty-and-now do like this:
> #include <stdio.h>
>     main()
>     {
>           int c;
> 
>           printf("Hit any character to continue\n");
>           /*
>            *ioctl() would be better here; only lazy
>            * programmers do it this way:
>            */
>           system("/bin/stty cbreak");        /* or "stty raw" */
>           c = getchar();
>           system("/bin/stty -cbreak");
>           printf("Thank you for typing %c.\n", c);
> 
>           exit(0);
>     }
> (Taken from UNIX FAQ,

It does not look to be very portable or good style though.
( very subjective )

> http://www.cis.ohio-state.edu/hypertext/faq/usenet/unix-faq/faq/part4/faq-doc-1.html
> )
> You may want also to look at:
> http://www.geek-girl.com/unix.html	- UNIX reference desk
> which may help you in the future with questions like this. 
> --
> frodo@sharat.co.il	\/  There shall be counsels taken
> Stanislav Malyshev	/\  Stronger than Morgul-spells
> phone +972-2-5369213	/\  		JRRT LoTR.
> http://www.sharat.co.il/frodo/   whois:SM719-RIPE@whois.ripe.net
> 

  Alexander Indenbaum
  baum@actcom.co.il