Question on IO::SEEK_CUR

Hey i am abit confuse here. as i want to clarify something on this
IO:SEEK_CUR. For example i have a hoho.txt contains “sure”. and i
execute this code.

f = File.new(“hoho.txt”,“r”)
while a = f.getc
puts a.chr
f.seek(1, IO::SEEK_CUR)
end

The ans prints out:
s
r

isn’t ‘u’ should be printed instead of ‘r’? because 1, means after the
character ‘s’, so it will be ‘u’ isn’t it?

The f.seek moves the read pointer on by 1 position. With other words: It
skips the next character.

If you would pass 0 to f.seek instead of 1, you would get the next
character.

Ronald F. wrote in post #1185057:

The f.seek moves the read pointer on by 1 position. With other words: It
skips the next character.

If you would pass 0 to f.seek instead of 1, you would get the next
character.

Thanks a lot :slight_smile: