On this page
  1. ftell
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

ftell

Prev: fseek | Up: stdio.h | Next: fflush
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — ftell
Tags: #public #prog #c #stdlib #stdio #tier/standard


Include

#include <stdio.h>

Signature & Overview

long ftell(FILE *stream);

Returns the current byte offset in stream (or -1L on error).

Notes & Pitfalls

Example

#include <assert.h>
#include <stdio.h>

int main(void) {
    FILE *f = tmpfile();
    fputs("1234", f);
    assert(ftell(f) == 4);
    fclose(f);
}

Linked from

Related notes