| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | getc() |
On 13 Jan 97 10:14:10 Bob Lawrence typed to Niels Petersen ....
Hi Bob
>> How do they read from a file in a block?
> NP> A file read (at the lowest level) places one sector (512 bytes)
> NP> into a particular place in memory allocated for that purpose.
> This is what Paul said, but it doesn't work in practice.
What I wrote is _exactly_ what happens at the machine level regardless
of what programming language you are using.
In your following statement you confirm that a block read is quicker.
> If I read
> characters using getc() one at a time, it is much slower than using
> fread() which reads to a buffer... and then run down the buffer.
> NP> If you know where it is (I've forgotten how to find out) then
> NP> access to the data is easy.
> (grin) Use fread(buffer, 512, 1, filename)...
I don't understand C, but I think you will find that the buffer yo are
using in C is NOT the machine area that is set aside as per my
statement.
> NP> IOW it reads a sector from the file regardless of whether your
> NP> program asks for 1 byte or a block.
> No, it doesn't.
Why say no it doesn't and then say....
> What you say is probably true,
This C programing has twisted your brain completely :-)
> but every time I call getc() it must
> read the sector again, move the file pointer up one, and take the
^^^^^^^^^^^^^^^^^^^^^^
Exactly as i said.
> NP> IOW it reads a sector from the file regardless of whether your
> NP> program asks for 1 byte or a block.
Is it clear now :-)
Niels
* OLR 5.1 * "Before God we are all equally wise Ä and equally foolish."
Ä Einstein
--- FMail/386 0.98
* Origin: Murphys Madhouse - All reality is aspect dependant - (3:670/213.232)SEEN-BY: 711/934 712/610 624 @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™.