ttyname() - question

Uri Blumenthal uri at arnor.UUCP
Fri Sep 1 04:39:19 AEST 1989


>From article <192700003 at hobbiton>, by fieland at hobbiton.prime.com:
> 
> tried this out on another Sun without the windows up.
> 
> Sure enough, the call in Main got the ttyname and the
> call in test didn't.
> 
> Clearly, results are system dependent.
> So how about it??? Any answers out there??????

This definitely works correctly (AIX system):
-------------------
#include <stdio.h>
void test()
{
	char *ttyname();

	printf("test: %s\n", ttyname(2));

}

main()
{
	char *ttyname();

	printf("main: %s\n", ttyname(2));
	test();

	exit(0);

}
-------------------------------

Points to be made:
	
	a) %s in 'printf' statement;

	b) the manual says:

		char *ttyname(fildes)
		int  fildes;

	   and when you call 'ttyname' WITHOUT proper parameter -
	   it does work from 'main', but doesn't work in subroutines.
	   Why? Implementation details, who cares?

Regards,
Uri.
________________
<Disclaimer>



More information about the Comp.lang.c mailing list