Read a text file in any position.

Giovanni Di Maria calimero22 at yahoo.it
Fri Jan 18 09:15:26 UTC 2019


On Friday, 18 January 2019 at 08:49:08 UTC, bauss wrote:
> On Friday, 18 January 2019 at 08:10:25 UTC, Giovanni Di Maria 
> wrote:
>> Hi All
>> I have a text file like this:
>>
>> 111111
>> 222222
>> 333333
>> 444444
>> 555555
>> 666666
>> 777777
>> ......
>>
>> I execute these functions:
>>
>> i = archive.readln();
>> i = archive.readln();
>> i = archive.readln();
>> i = archive.readln();
>>
>> so "i" is 444444.
>>
>> Is there a method to move the pointer of file to beginning of 
>> file or to any position (for example back to 2nd row), without 
>> to close the file?
>>
>> Thank you very much.
>> Regards
>> Giovanni
>
> Use File (https://dlang.org/library/std/stdio/file.html)
>
> And seek() (https://dlang.org/library/std/stdio/file.seek.html)
>
> And then one of its read functions.
>
> rawRead will let you read the raw bytes at the position.




Thank you very very much.
Giovanni


More information about the Digitalmars-d-learn mailing list