简体   繁体   中英

How does fgetc work internally

Does it actually read character by character or does it read some bytes into the kernel buffer and return to the user- character by character?

Is it the same with fgets ?

Let me say I use glibc and a gcc compiler.

Almost right. A typical modern implementation that does have a user/kernel separation stores the bytes in a user buffer , not in a kernel buffer. Thus many calls to fgetc actually trigger few true system calls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM