www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/26/05:42:53

Date: Tue, 26 Oct 1999 08:31:20 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp AT delorie DOT com
Subject: Re: best way to read selected data from a file?
In-Reply-To: <3813D291.5F1FF7A1@montana.com>
Message-ID: <Pine.SUN.3.91.991026082739.17216G-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Ryan wrote:
 
> But what If I want to go straight to line 15 and read that line?

Besides the other suggestions, there's one that frequently gets 
overlooked: read the entire file into memory, then scan the buffer 
counting \n characters; when you have seen 14 of them, you are at the 
beginning of line 15.

Given the amount of memory available to you in DJGPP, this is much 
simpler than messing with fseek, fscanf, and the like.  More often than 
not, it will be also faster.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019