It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center。
7年前关闭。
该程序的输出是什么?
父级的值可以为20,否则子级可以通过其自身的变量“值”的副本获得
7年前关闭。
#include "stdafx.h"
#include<sys/types.h>
#include<stdio.h
#include<unistd.h>
int value=5;
int _tmain(int argc, _TCHAR* argv[]){
pid_t pid;
pid=fork();
if(pid==0)
{
value+=15;
}
else if(pid>0)
{
wait(NULL);
printf("Parent value:=%d",value);
exit(0);
}
return 0;
}
该程序的输出是什么?
父级的值可以为20,否则子级可以通过其自身的变量“值”的副本获得
最佳答案
父级将拥有自己的变量“值”的副本,因此输出为5
您是否尝试执行以上代码?