Chapter Contents |
Previous |
Next |
ctermid |
Portability: | POSIX.1 conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
CAUTION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <lcio.h> char *ctermid(char *termid);
The synopsis for the POSIX implementation is as follows:
#include <unistd.h> char *ctermid(char *termid);
This set of header files requires the definition of an appropriate feature test macro. See Feature Test Macros for more information.
DESCRIPTION |
ctermid
returns the filename of the user's terminal.
string
is the terminal filename.
The argument to
ctermid
should be
NULL
, or it should address
a character array (
termid
) whose size is
at least
L_ctermid
. The symbol
L_ctermid
is defined in the header file
<lcio.h>
(or
<stdio.h>
if
an appropriate feature test macro is defined).
If the argument is not
NULL
, the filename (followed by '\0') is copied into the area addressed
by
termid
. If the argument is
NULL
, the filename can only be accessed by using the value returned
by
ctermid
.
RETURN VALUE |
The return value is a pointer to the filename.
If the argument to
ctermid
is
NULL
(the norm), the return value is in static storage and may be overlaid
by the next call to
ctermid
.
CAUTION |
If a noninteractive program calls
ctermid
, an attempt to open the filename returned
by
ctermid
may fail.
EXAMPLE |
This example sends a message to a terminal:
#include <lcio.h> main() { /* Open the terminal for writing. */ FILE *termfile; /* Assign name of interactive terminal to termfile. */ termfile = fopen(ctermid(NULL), "w"); if (!termfile) { printf("File could not be opened.\n", stderr); exit(1); } /* Print message to interactive terminal. */ fprintf(termfile, "This is a test message.\n"); fclose(termfile); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.