File Operation

Can you tell me if I can move to a perticular Line number like ‘C’?

2009/10/26 Subhas M. [email protected]:

Can you tell me if I can move to a perticular Line number like ‘C’?

What C library allows to “move to a particular line number”? I am not
aware of something like that and it can work efficiently only if you
have an index or lines with uniform length.

Please look at IO#tell and IO#seek. If you want line by line jumping
there is no other way as to read the file from the beginning and stop
at the appropriate line number.

The only option to speed that up is to build up an index of lines and
then use IO#seek to position accordingly. If you also write to the
file that approach will soon get very complicated.

Kind regards

robert

Thanks Robert

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs