| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | getc() |
BL> I don't understand why fread() is faster than getc(). How do BL> they get the file data into the buffer? Don't you have to move BL> it one character at a time? RM> yes, but getc() does it with a call to a C function for *each* RM> character, instead of reading a bunch of chars with just one RM> function call. Actually, getc() is a macro that only calls the fgetc() function when the fgetc() buffer is empty. I found this out for myself (after asking Paul with no success) by looking in the stdio.h file. But I still don't know how fgetc() works (although Paul has told me he has tested it a million times without discovering which is faster). This information was of no value to me whatsoever (as usual). Paul *seems* to be saying that if I don't set the stream buffer with sefbuf() then fgetc() does not use a buffer. I've been trying to get Paul to be explicit, but as always when he's not sure he becomes contradictory. I can't make setbuf() work for me. I think what you have to do is use setvbuf() with the buffer named NULL, which creates a buffer on the heap named the way fgetc() can use it. But of course, Paul prefers to be obscure. I think he is that shit who was always looking over your shoulder at school; the one who never thought for himself and never knew anything of substance but knew all the buzzwords... Rod Edwards, Paul Speed - his name is on the tip of my bum. Every test I run has getc() 3-5 times slower than the buffered fread(). RM> I learned this the hard way with output - it's a lot faster to RM> write a whole string to the screen than it is to write the RM> string one char at a time. Yes... one of the first things I did in VB was to try various ways of doing things in a loop. Regards, Bob ___ Blue Wave/QWK v2.12 @EOT: ---* Origin: Precision Nonsense, Sydney (3:711/934.12) 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™.