isatty -- Test for Terminal File

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 OpenEdition terminal. isatty returns 0 for the DDname SYSTERM when called under MVS batch.

RETURN VALUE

A nonzero value is returned if the file number is associated with an interactive terminal; otherwise, 0 is returned.

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

fattr, fstat, fterm

SEE ALSO

I/O Functions

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.