网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

对于如下C语言程序 int main() { pid_t pid; int x=1; pid = fork(); if(pid==0) printf("I am the child process, x=%d\n", ++x); else printf("I am the parent process, x=%d\n", --x); } 在UNIX操作系统中正确编译链接后,其正确的运行结果是

A.I am the child process, x=2

B.I am the parent process, x=0

C.I am the parent process, x=2

D.I am the child process, x=0


参考答案

更多 “ 对于如下C语言程序 int main() { pid_t pid; int x=1; pid = fork(); if(pid==0) printf("I am the child process, x=%d\n", ++x); else printf("I am the parent process, x=%d\n", --x); } 在UNIX操作系统中正确编译链接后,其正确的运行结果是A.I am the child process, x=2B.I am the parent process, x=0C.I am the parent process, x=2D.I am the child process, x=0 ” 相关考题
考题 请分析以下程序。 int main() { pid_t pid; pid = fork(); if(pid==0) printf("I am the child process, my process ID is%d\n",getpid()); else printf("I am the parent process, my process ID is%d\n",getpid());} 那么,该程序正确运行后的结果是A.I am the child process, my process ID is 3744 I am the parent process, my process ID is 3987B.I am the child process, my process ID is 3744C.I am the parent process, my process ID is 3987D.不输出任何信息

考题 当waitpid函数的pid参数设置为()表示等待任一子进程终止。A.pid==-1B.pid==0C.pid>0D.pid 当waitpid函数的pid参数设置为()表示等待任一子进程终止。A.pid==-1B.pid==0C.pid>0D.pid

考题 以下程序的输出结果是______。 fun(int *s,int *p) { static int t=3; *p=s[t]; t--; } main() { int str[]={1,2,3,4},i,m=0; for(i=0;i<4;i++) {fun(str,m); printf("%d",m); } printf("\n"); }A.0B.444412C.1234D.4321

考题 有以下程序: void fun(int *a,int i,int i) { int t; if(i<j) { t==a[i];a[i]=a[j];a[i]=t; i++; j--; fun(a,i,j); } } main() { int x[]={2,6,1,8),i; fun(x,0,3), for(i=0;i<4;i++) printf("%2d",x[i]); printf("\n"); } 程序运行后的输出结果是( )。A.1268B.8621C.8162D.8612

考题 请选出以下程序的输出结果_______。 includesub(int*s,inty){ static int t=3,y=s[t];t 请选出以下程序的输出结果_______。 #include<stdio.h> sub(int*s,inty) { static int t=3, y=s[t];t-; } main() { int a[]={1,2,3,4},i,x=0; for(i=0;i<4;i++){ sub(a,x);printf("%d",x);} printf("\n"); }A.1234B.4321C.0D.4444

考题 嵌入式Linux操作系统中任务的创建过程如下,以下说法正确的是(53)。void main( ){ int pid;pid= fork( )if(pid>0)printf("parent task");else if(pid= =0){ printf("child task") ;execvp ("MyTash", NULL);}}A.子任务的创建基于fork/exec模型B.子任务的创建基于spawn模型C.先为子任务分配内存空间,再分配相应的数据结构D.直接为子任务分配一个全新的地址空间,然后再将其代码装入运行

考题 请选出以下程序的输出结果()。includesub(int *s,int y){static int t=3; y=s[t];t--;} 请选出以下程序的输出结果( )。 #include <stdio.h> sub(int *s,int y) { static int t=3; y=s[t];t--; } main() { int a[]={1,2,3,4},i,x=0; for(i=0;i<4;i++) { sub(a,x);printf("%d",x); } printf("\n"); }A.1234B.4321C.0D.4444

考题 有以下程序:include void f(int * x,int * y) int t;t= *x; *x= *y; *y=t;main ( ){in 有以下程序:#include <stdio.h>void f(int * x,int * y) int t; t= *x; *x= *y; *y=t;main ( ){ int a[8] = { 1,2,3,4,5,6,7,8} ,i, * p, * q; p=a;q =a[7]; while(p<q) { f(p,q) ;p ++ ;q --; } for(i =0;i<8;i ++ ) printf(" % d," ,a[i]); }程序运行后的输出结果是( )。A.8,2,3,4.,5,6,7,1,B.5,6,7,8,1,2,3,4,C.1,2,3,4,5,6,7,8,D.8,7,6,5,4,3,2,1,

考题 UNIX操作系统中,fork()系统调用用于创建进程。仔细阅读、分析下列程序,假设程序正确运行并创建子进程成功,那么,输出到屏幕的正确结果是main() { pid_t pid; pid = fork(); if (pid = = 0) printf ("Hello World\n"); else if (pid >0) printf ("Hello World\n"); else printf ("Hello World\n"); }A.什么都没有B.1行Hello WorldC.2行Hello WorldD.3行Hello World