getting users' tty # into a C program

Dave Kraft davek at lakesys.UUCP
Mon Mar 6 09:15:56 AEST 1989


In article <9794 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> 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?
> 
> 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);
}

(Plus I grepped around in all of the include files for ttyname, and I couldn't
find it)  Is there anything I'm doing wrong in the above program?? 
Thanks in advance.
Dave

-- 
davek at lakesys.lakesys.com -or-
uunet!marque!lakesys!davek
"The meek will inherit the earth, the rest of us will go to the stars"
-- 'Omni' (magazine) button



More information about the Comp.lang.c mailing list