'\"macro stdmacro
.if n .pH g3s.ctermid @(#)ctermid	40.10 of 10/26/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} ctermid 3S "C Programming Language Utilities" "\&"
.if \nX=1 .ds x} ctermid 3S "C Programming Language Utilities"
.if \nX=2 .ds x} ctermid 3S "" "\&"
.if \nX=3 .ds x} ctermid "" "" "\&"
.TH \*(x}
.SH NAME
\f4ctermid\f1 \- generate file name for terminal
.SH SYNOPSIS
\f4#include <stdio.h>\fP
.PP
\f4char \(**ctermid (char \(**s);\f1
.SH DESCRIPTION
\f4ctermid\fP
generates the path name of the controlling
terminal for the current process, and stores it in a 
string.
.PP
If
.I s\^
is a
\f4NULL\fP
pointer, the string is stored in an internal static area,
the contents of which are overwritten at the next call to
\f4ctermid\fP,
and the address of which is returned.
Otherwise,
.I s\^
is assumed to point to a character array of at least
\f4L_ctermid\f1
elements; the path name is placed in this array and the value of
.I s\^
is returned.
The constant
\f4L_ctermid\f1
is defined in the
\f4stdio.h\fP
header file.
.SH SEE ALSO
\f4ttyname\fP(3C).
.SH NOTES
The difference between
\f4ctermid\fP
and
\f4ttyname\fP(3C)
is that
\f4ttyname\fP
must be handed a file descriptor and returns the actual name of
the terminal associated with that file descriptor, while
\f4ctermid\fP
returns a string
\f1(\f4/dev/tty\f1)
that will refer to the
terminal if used as a file name.
Thus
\f4ttyname\fP
is useful only if the process already has at least one file open
to a terminal.
.\"	@(#)ctermid.3s	6.3 of 10/20/83
.Ee
