| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | tic |
PE> fgets() would be faster after fread() if the fread() had just
PE> loaded a 512-byte buffer for you, and now your fgets is just
PE> reading out of the buffer, instead of the fgets() having to do
PE> both.
Eh? I thought everything got closed down at the end of the function?
It *must* do... otherwise you'd run out of stack space.
PE> It's a macro instead of a function call.
BL> Doesn't that mean it just calls another function?
PE> No. It can, but normally getc() is implemented by a 6-line
PE> macro which just accesses a the buffer directly.
Whooo... can you do that??
... [later - is this it?]
#define getc(f) \
((--((f)->level) >= 0) ? (unsigned char)(*(f)->curp++) : \
_fgetc (f))
Gee... 6 lines, my arse. This opens up whole new possibilities! I
already knew that this was one of the things C had over Pascal, but
that's terrific! But it does call fgetc(F) to fill up the buffer.
BL> What's a one-byte buffer called?
PE> Pass. Who's using a 1-byte buffer? BFN. Paul.
I assumed getc() was just calling the other one every time... it
never occurred to me that it could read straight out of the stream and
top it up every so often.
Regards,
Bob
___ Blue Wave/QWK v2.12
@EOT:
---
* Origin: Precision Nonsense, Sydney (3:711/934.12)SEEN-BY: 711/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™.