Why fgetc too slow?

后端 未结 2 1775
死守一世寂寞
死守一世寂寞 2021-01-23 01:26

I\'ve written a program that reads an whole file via fgetc:

while ((c = fgetc(f)) != EOF) { ... }

But the program is too slow. Whe

2条回答
  •  孤独总比滥情好
    2021-01-23 01:48

    With fgetc you not only get more function calls (each one has its overhead), but fgetc may also takes locks in multi-threaded application (this is mandated for instance by POSIX).

提交回复
热议问题