getting users' tty # into a C program

-for inetd server command nobody at tekecs.GWD.TEK.COM
Wed Mar 8 04:56:07 AEST 1989


In article <444 at lakesys.UUCP> davek at lakesys.UUCP (Dave Kraft) writes:
>Here's what I tried:
>
>main()
>{
>	char *name;
>
>	*name=ttyname();
>	printf("%s\n", *name);
>}


Try this;  It should work.

main()
{
char name[1025];

	strcpy(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.

Close, but not quite.  Try this:

% ar t /lib/libc.a | grep ttyname

It should find a ttyname.o  This is included by the loader when ld'ing your
program automatically.


Hope this helps,

	Jeff Beadles

--
Jeff Beadles  Utek Sustaining Engineering
jeff at quark.WV.TEK.COM



More information about the Comp.lang.c mailing list