Skip to main content

Sequential vs Random Access Files in C


1. Sequential Access Files

In sequential access, data is read or written one record at a time, in order — from the beginning to the end. You cannot jump to a specific position; you must read through everything before it. Common functions: fgetc(), fgets(), fprintf(), fscanf()

Example: Menu-Driven Sequential File


2. Random Access Files

In random access, you can jump directly to any position in the file using fseek() — no need to read through the whole file first. This is much faster for large files. Key functions: fseek(), ftell(), rewind()

fseek() Syntax

Example: Random Access with Student Records


Comparison