Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!analog2!gandhi!ambarish From: ambarish@gandhi.UUCP (Ambarish Malpani) Newsgroups: comp.lang.c Subject: Re: getting users' tty # into a C program Summary: Using ttyname() Message-ID: <386@gandhi.UUCP> Date: 9 Mar 89 00:29:39 GMT References: <441@lakesys.UUCP> <9794@smoke.BRL.MIL> <444@lakesys.UUCP> Organization: Analog Design Tools Inc., Sunnyvale, CA. Lines: 31 In article <444@lakesys.UUCP>, davek@lakesys.UUCP (Dave Kraft) writes: > In article <9794@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: > > 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? > > > > Most UNIX systems have a ttyname() library function for doing this. > > It doesn't work perfectly... > Here's what I tried: > > main() > { > char *name; > > *name=ttyname(); > printf("%s\n", *name); > } > > Dave > try: main() { char *name, *ttyname(); name = ttyname(file_id_you_are_interested_in_eg_0_for_stdin); printf("%s\n", name); }