Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rewind(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                               rewind(3C)



        _________________________________________________________________
        rewind                                                   function
        Reposition a file to its beginning.
        _________________________________________________________________


        Calling Sequence

        #include <stdio.h>
        void rewind();
        FILE *fp;
        rewind(fp);

        where fp is a pointer to a FILE packet.


        Description

        Use the rewind function to reposition a file to its beginning.
        The include file stdio.h defines this function.


        Returns

        The rewind function does not return anything.


        Related Functions

        See also the fseek function.


        Example

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

        #include <stdio.h>
        #define MAX     136

        void   rewind();
        FILE  *fp, *fopen();
        char   stringbuf[MAX], *strcat();
        int    i, c;

        main(argc, argv)

        int    argc;
        char  *argv[];
        {
            fp = fopen(argv[1], "r");
            c = atoi(argv[2]);



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





                                                               rewind(3C)



            for(i = 1; i<= c; i++) {
                fgets(stringbuf, MAX, fp);
                printf("String %d:  %s", i, stringbuf);
            }
            rewind(fp);
            fgets(stringbuf, MAX, fp);
            printf("The first string was: %s\n", stringbuf);
        }

        A call to the program test with

        x test inputstr 3

        where the file input_str contains

        I am alpha.
        I am beta.
        I am gamma.
        I am delta.
        I am epsilon.

        generates the output

        String 1: I am alpha.
        String 2: I am beta.
        String 3: I am gamma.
        The first string was: I am alpha.

        since the file rewinds after the third call to fgets.

























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



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