fork的微妙问题2
1: /*
2: author:justinzhang
3: email:uestczhangchao@gmail.com
4: time:2012-8-30 22:53:33
5: desc: from a interview question, fork plus printf buffer is a littel tricky~~
6: */
7: #include <stdio.h> 8: #include <stdlib.h> 9: 10: int main()
11: {12: int i = 0;
13: for(i=0; i<2; i++)
14: { 15: fork();16: printf("-");
17: fflush(stdout);18: // printf("-\n");
19: } 20: exit(0); 21: }

浙公网安备 33010602011771号