RandomAccessFile

this photo belongs to chapter 18,introduction to I/O by liang

After I saw that photo, I thought about an example:

Suppose I have a txt file that have these numbers:

1 2 3 4 5 6

numbers with one space.

I want to read this file so the file pointer points to “3” , read numbers until “5”

I don;t know how to use fseek() for this situation. How to adjust it?

Another question:

When I save a number in txt file, Is it a number or character?

You need to know the offset of where to start. The position starts from 0.
So for number “3”, you’d fseek to position 4

A file is a series of bytes. Depending on the charset / file encoding, the number of bytes per character can be different.