0% found this document useful (0 votes)
17 views10 pages

Random Access File Operations Explained

Random access files allow data to be read and modified in a non-sequential manner, enabling direct access to records such as the last one. Key functions for processing these files include fseek() for setting the pointer position, ftell() for retrieving the current pointer position, and rewind() for resetting the pointer to the beginning of the file. An example demonstrates file operations, showing a file size of 27 bytes with specific content.

Uploaded by

brokenhero267
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views10 pages

Random Access File Operations Explained

Random access files allow data to be read and modified in a non-sequential manner, enabling direct access to records such as the last one. Key functions for processing these files include fseek() for setting the pointer position, ftell() for retrieving the current pointer position, and rewind() for resetting the pointer to the beginning of the file. An example demonstrates file operations, showing a file size of 27 bytes with specific content.

Uploaded by

brokenhero267
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Random access file

Random Access
 Data can be read and modified
randomly.
 If we want to read the last record we
can read it directly.
 It takes less time when compared to
sequential file.
The following functions are used for random
access file processing.
 fseek()
 ftell()
 rewind()
fseek()
 It is used for seeking the pointer
position in the file at the specified byte.
SYNTAX:
fseek(file pointer, displacement,
pointer position);
[SEEK_SET,SEEK_CUR,SEEK_END]
ftell()
 The function returns the value of the current
pointer position.
 The value is count from the beginning of the
file.

SYNTAX:
ftell(fptr);
rewind(fptr)
 The function is used to move the file
pointer to the beginning of the given
file.
SYNTAX:
rewind(fptr);
Example Program
EXPLORING FILE OPERATIONS
Output:
File size:27 bytes
Contents of the file:
Hello, this is a test file.

You might also like