Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fgetc(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                fgetc(3C)



        _________________________________________________________________
        fgetc                                                    function
        Read a character from a specified file.
        _________________________________________________________________


        Calling Sequence

        #include <stdio.h>

        FILE *fp;
        int fgetc(), nextchar;
        nextchar = fgetc(fp);



          where   nextchar is the character to get.

                  fp is a pointer to a FILE packet.



        Description

        The fgetc function reads a character from a general file.  It
        assumes that the file is open.  The include file stdio.h defines
        fgetc.

        If you define the macro _NEXPAND, the stdio.h macros getc and
        putc resolve to the library functions fgetc and fputc.  That is,
        your C program will call the library functions instead of the
        macros.  This allows you to set a breakpoint at the routine while
        debugging.


        Returns

        The function returns EOF (-1) on end of file or error; otherwise
        it returns the character read.


        Related Functions

        See also the dg_fgets, fgets, fputc, getc, getchar, gets, getw,
        and ungetc functions.


        Example

        /* Program test for the fgetc() function */




        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                fgetc(3C)



        #include <stdio.h>

        FILE    *fopen(), *fp;

        int     i = 1, fgetc(), c;

        main(argc, argv)
        int     argc;
        char    *argv[];
        {
            while (i < argc) {
                fp = fopen(argv[i], "r");
                printf("%c", c = fgetc(fp));
                i++;
            }
        }

        A call to program test with the valid filenames



          char_in_a     /* file consisting of aaaaa */

          char_in_b     /* file consisting of bbbbb */

          char_in_c     /* file consisting of ccccc */

          char_in_d     /* file consisting of ddddd */

        generates the output

        abcd






















        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026