TIP: Click on subject to list as thread! ANSI
echo: aust_avtech
to: Bob Lawrence
from: Niels Petersen
date: 1997-01-12 08:29:02
subject: getc()

On 10 Jan 97  08:55:58 Bob Lawrence typed to Paul Edwards ....

Hi Bob



 >   I'm trying to read a string into a buffer, and I have to find the
 > nul terminator to know where to stop. getc() is one way to do this,
 > one character at a time... a way you said was as fast as fread() into
 > a buffer, where I look for the character one at a time in the buffer.
 > You
 > are WRONG. It's much quicker to read a block from the file, and then
 > process the block. I don't know why this should be. How do they read
 > from a file in a block?

 A file read (at the lowest level) places one sector (512 bytes) into a
 particular place in memory allocated for that purpose.

 If you know where it is (I've forgotten how to find out) then access to
 the data is easy.

 IOW it reads a sector from the file regardless of whether your program
 asks for 1 byte or a block.

 Hope this helps


Cheers
Niels

* OLR 5.1 *  "How good do you have to be to qualify as good?" - Calvin

--- FMail/386 0.98
* Origin: Hang up your logic over there. (3:711/934.22)
SEEN-BY: 711/808 934 712/610
@PATH: 711/934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.