Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!mcdchg!chinet!john From: john@chinet.chi.il.us (John Mundt) Newsgroups: comp.lang.c Subject: Re: getting users' tty # into a C program Message-ID: <7871@chinet.chi.il.us> Date: 5 Mar 89 19:36:17 GMT References: <441@lakesys.UUCP> Reply-To: john@chinet.chi.il.us (John Mundt) Organization: Chinet - Public Access Unix Lines: 21 In article <441@lakesys.UUCP> davek@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@chinet.chi.il.us (312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem