getting users' tty # into a C program

John Mundt john at chinet.chi.il.us
Mon Mar 6 05:36:17 AEST 1989


In article <441 at lakesys.UUCP> davek at lakesys.UUCP (Dave Kraft) writes:
>I am writing a C program that need a user's tty number (i.e. tty3A).  Is there
>any internal/external function that can accomplish this? 

Try ttyname(3C) which will return a pointer to a null-terminated 
character string of the terminal device associated with the file
descriptor you send it.  So you can do something like

char *tty_ptr, *strrchr(), *ttyname();

	tty_ptr = strrchr(ttyname(0)) + 1;

assuming that the tty's have something like /dev/ttynnn or the
like.


-- 
---------------------
John Mundt   Teachers' Aide, Inc.  P.O. Box 1666  Highland Park, IL
john at chinet.chi.il.us
(312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem  



More information about the Comp.lang.c mailing list