ttyname() - question

andre andre at targon.UUCP
Wed Aug 30 22:25:05 AEST 1989


In article <99 at lkbpyr.UUCP> jonas at lkbpyr.UUCP (Jonas Heyman) writes:
]I was wondering why this work:
]#include <stdio.h>
]main()
]{
]       char *term;
]       char *ttyname();
]       term=ttyname();
]       printf("%d",term);
]}

Because you were lucky,

]And why this don't:
]--------------------------------------
]#include <stdio.h>
]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



More information about the Comp.lang.c mailing list