Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wugate!uunet!bywater!arnor!uri From: uri@arnor.UUCP (Uri Blumenthal) Newsgroups: comp.lang.c Subject: Re: ttyname() - question Message-ID: <388@arnor.UUCP> Date: 31 Aug 89 18:39:19 GMT References: <192700003@hobbiton> Organization: IBM Corp., Yorktown NY Lines: 50 From article <192700003@hobbiton>, by fieland@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 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. ________________