Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
printf如果给出以下代码段,我想知道打印“PROCESS”多少次:
printf
int main() { printf("PROCESS"); fflush(); fork(); fork(); }
请解释有无的逻辑fflush();。
fflush();
它将存储在 stdio 缓冲区中的数据写入控制台。从而进入带有明确缓冲区的过程 - 即。没有多次打印出“PROCESS”
PS:假设你的意思fflush(stdout);
fflush(stdout);