您的位置:首页 > 其它

缓冲区问题:子进程会复制父进程的缓冲区

2016-07-22 10:16 92 查看
From: 《王道-程序员求职宝典P323》
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
int ret = 0;

int i = 0;

for( i = 0; i < 2; i++ )
{
fork();
printf( "a" );
}

return ret;
}

// 输出8个a

=============================================================

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
int ret = 0;

int i = 0;

for( i = 0; i < 2; i++ )
{
fork();
printf( "a\n" );
}

return ret;
}

// 输出6个a
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  缓冲区