学习决赛,我遇到了这个问题.他们询问以下代码执行printf的次数:
#include "csapp.h"
void doit() {
Fork();
Fork();
printf("hello\n");
return;
}
int main()
{
doit();
printf("hello\n");
exit(0);
}
Run Code Online (Sandbox Code Playgroud)
解决方案说它printf执行了8次,但我无法弄清楚原因.我一直试图绘制代码中发生的事情的图片,但我的图片看起来好像只执行了4次.