Xref: utzoo comp.lang.c:21328 comp.lang.c++:4510 Path: utzoo!utgpu!watmath!att!dptg!rutgers!apple!brutus.cs.uiuc.edu!wuarchive!wugate!uunet!mcsun!hp4nl!targon!andre From: andre@targon.UUCP (andre) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: ttyname() - question Message-ID: <612@targon.UUCP> Date: 30 Aug 89 12:25:05 GMT References: <99@lkbpyr.UUCP> Reply-To: andre@targon.UUCP (andre) Organization: Nixdorf Computer BV., DO, P.O. Box 29,Vianen, The Netherlands Lines: 41 In article <99@lkbpyr.UUCP> jonas@lkbpyr.UUCP (Jonas Heyman) writes: ]I was wondering why this work: ]#include ]main() ]{ ] char *term; ] char *ttyname(); ] term=ttyname(); ] printf("%d",term); ]} Because you were lucky, ]And why this don't: ]-------------------------------------- ]#include ]main() ]{ ] test(); ]} ] ]test() ]{ ] char *term; ] char *ttyname(); ] term=ttyname(); ] printf("%d",term); ]} because you were not lucky, there was something else on the stack. The *MANUAL* says, char *ttyname(filedes). So if you use in on stdin it will work: term=ttyname(0); -- \---| AAA DDDD It's not the kill, but the thrill of the chase. \ | AA AAvv vvDD DD Ketchup is a vegetable. /\ \ | AAAAAAAvv vvDD DD {nixbur|nixtor}!adalen.via _/__\__\| AAA AAAvvvDDDDDD Andre van Dalen, uunet!hp4nl!targon!andre