Random Access
File Handling
Ms. Mamoona Tasadduq
:
, Outline
• Random Access Files
• Creating a Random Access File
• Writing Data Randomly to a Random
Access File
• Reading Data Sequentially from a
Random Access File
• Case Study: A Transaction Processing
Program
– Updating Data Randomly to a Random
Access File
2
, Reading Data from a Sequential
Access File
• Sequential access file
– Cannot be modified without the risk of destroying other data
– Fields can vary in size
• Different representation in files than internal
representation
• 1, 34, -890 are all ints, but have different sizes on
disk/file
– 1 takes 1 byte, 34 takes 2 bytes, -890 takes 4 bytes.
– However, internally (in memory), they all have same size: 4 bytes
(assuming int takes 4 bytes)
So, what difference does it make???