Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dg_fgets(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                             dgfgets(3C)



        _________________________________________________________________
        dgfgets                                                 function
        Read a line from a file into a character buffer.
        _________________________________________________________________


        Calling Sequence

        #include <stdio.h>
        FILE *stream;
        char *stringbuf, *dgfgets();
        int max;
        dgfgets(stringbuf, max, stream);



          where   stringbuf is a byte pointer to the character buffer
                  you supply.

                  max is the number of characters to be transferred.

                  stream is a pointer to the FILE structure that
                  represents the file to be read from.



        Description

        The dg_fgets function reads a line from a file into a character
        buffer that you supply.  The data transfer stops when one of the
        following occurs:

        *    An error

        *    The end of file.

        *    The function reads max - 1 characters

        *    The function reads one of the following characters:

                  New Line         \012 or \n
                  carriage return  \015 or \r
                  form feed        \014 or \f
                  null             \000

        Note that the calling sequence for dg_fgets is identical to that
        of fgets.  The only difference between the functions is that
        dg_fgets uses the Data General default line terminators, while
        fgets uses only the New Line character as a terminator.

        See the section "Input/Output Functions and Macros" in Chapter 1



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





                                                             dgfgets(3C)



        for information on buffering with dg_fgets.


        Returns

        The dg_fgets function returns the address of stringbuf if the
        read was successful.  Otherwise, it returns a null (0).


        Related Functions

        See also the fgets, fputs, getc, fgetc, getchar, getw, and ungetc
        functions.


        Example

        The following program reads a line from the standard input file
        and writes it out.
        #include <stdio.h>


        #define LSIZE  80       /* number of characters on a line */


        char line[LSIZE];       /* line to be read in */

        main(){
            printf("Type a line: ");
            if (dg_fgets(line, LSIZE, stdin) == line)
                printf("You typed %s", line);
            else
                perror("Error in read ");
        }
        If you type

        O say, can you C?

        the generated output is

        You typed O say, can you C?













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



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