Files have a position marker that tracks where the next read or write occurs. Use seekg for input position and seekp for output position. Both move to a specific byte offset. Write file.seekg(0) to go to the beginning or file.seekg(0, ios::end) to go to the end.
The second parameter sets the reference point for the offset. Random access lets you jump to any position without reading everything before it. This works best with binary files where record sizes are predictable.