![]() Chapter Contents |
![]() Previous |
![]() Next |
| isatty |
| Portability: | POSIX.1 conforming, UNIX compatible |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <lcio.h> int isatty(int fn);
The syntax for the POSIX implementation is
#include <sys/types.h> #include <unistd.h> int isatty(int fn);
| DESCRIPTION |
isatty
tests whether the file associated with file number
fn
is an interactive terminal.
isatty
returns a non-zero value if the file number represents a TSO terminal, a CMS
terminal, or an USS terminal.
isatty
returns
0 for the DDname SYSTERM when called under OS/390 batch.
| RETURN VALUE |
| EXAMPLE |
#include <lcio.h>
#include <stdio.h>
double point[40];
main()
{
FILE *f;
int index = 0;
double sum = 0.0;
double avg ;
int nopoints;
int fn =0;
/* If stdin is the terminal, (fileno(stdin) is always 0). */
if (isatty(fn))
/* Tell user to enter data points - max. = 39. */
puts("Enter data points (-1 to indicate end of list).");
for(;;){
/* Read number; check for end of file. */
if (scanf("%le", &point[index]) <= 0)
break;
if (point[index] == -1) break;
sum += point[index];
++index;
}
nopoints = index;
avg = sum / nopoints;
printf("%d points read.\n", nopoints);
printf("%f = average.\n", avg);
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.