Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ftell(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                ftell(3C)



        _________________________________________________________________
        ftell                                                    function
        Return the current byte position in a file.
        _________________________________________________________________


        Calling Sequence

        #include <stdio.h>
        FILE *fp;
        long position, ftell();
        position = ftell(fp);


          where   position is the current byte position within a file.
                  fp is a pointer to an FILE stream.



        Description

        Use the ftell function to determine your current position in a
        file.  The include file stdio.h defines this function.


        Returns

        The ftell function returns the current position in a file, or -1
        if an error occurs.  Non-disk files will typically return -1.


        Example

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

        #include <stdio.h>
        #define EOF -1

        FILE    *fp, *fopen();
        int     next;
        long    position, ftell();

        main(argc, argv)
        int     argc;
        char    *argv[];
        {
            fp = fopen(argv[1], "r");
            while ((next = getc(fp)) != EOF) {
                putchar(next);
                printf(" %ld ", position = ftell(fp));
            }



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





                                                                ftell(3C)



        }

        A call to program test with the valid filename input_str, which
        contains

        My last byte.

        generates the output

        M 1 y 2 3 l 4 a 5 s 6 t 7 8 b 9 y 10 t 11 e 12 . 13












































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



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