getting users' tty # into a C program
Ambarish Malpani
ambarish at gandhi.UUCP
Thu Mar 9 10:29:39 AEST 1989
In article <444 at lakesys.UUCP>, davek at lakesys.UUCP (Dave Kraft) writes:
> 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);
> }
>
> Dave
>
try:
main()
{
char *name, *ttyname();
name = ttyname(file_id_you_are_interested_in_eg_0_for_stdin);
printf("%s\n", name);
}
More information about the Comp.lang.c
mailing list