/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that returns the integer file
descriptor associated with the named stream. */
#include <stdio.h>

int main() {
    int fildes;
    FILE *stream;
    char filename[9];

    strcpy (filename, "fileno.c");
    /* open file for reading only */
    if((stream = fopen(filename,"r")) == NULL) { 
        printf("cannot open file");
        exit(1);
    }
    fildes = fileno(stream);
    printf("\"%s\" has a file descriptor of %d.\n", filename, fildes);
    fclose(stream);
}
