首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
对于如下C语言程序 int main() { pid_t pid; int x=1: pid=fork(); if(pid==0) printf("I am the child process,x=%d\n"
对于如下C语言程序 int main() { pid_t pid; int x=1: pid=fork(); if(pid==0) printf("I am the child process,x=%d\n"
admin
2019-05-20
33
问题
对于如下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
I am the parent process.x=0
B、I am the child process,x=2
C、I am the parent process,x=0
D、I am the parent.process,x=2
I am the child process,x=0
答案
A
解析
计算机程序设计中的:fork()函数的返回值:若成功调用一次则返回两个值,子进程返回0,父进程返回子进程标记;否则,出错返回一1。运行后的输出为I am the child process,x=2 I am the parent,process,x=0。故本题答案选择A选项。
转载请注明原文地址:https://jikaoti.com/ti/4zA7FFFM
本试题收录于:
四级网络工程师题库NCRE全国计算机四级分类
0
四级网络工程师
NCRE全国计算机四级
相关试题推荐
在TCP/IP体系结构中,(66)________________协议可将IP地址转化为MAC地址;(67)________________协议属于应用层协议。
以下关于信息和数据的描述中,错误的是________________。
在面向对象方法中,采用(44)可将对象的内部实现讲行隐藏。一个对象通常由(45)组成。(45)
在某单处理机系统中,采用先来先服务调度算法。某一时刻,该系统中有4个进程P1、P2、P3、P4(假设进程按此顺序到达),其中P1为运行状态,P2为就绪状态,P3和P4为等待状态;且P3等待打印机,P4等待扫描仪。若P1释放了扫描仪,则下列进程中(
按照国际电话电报咨询委员会(CCITT)的定义,______属于表现媒体(PresentationMedium)。A.声音B.图像编码C.显示器D.光盘
在Word的编辑状态下,若要防止在段落中问出现分页符,可以通过单击鼠标右键在弹出的菜单中选择(1)命令;在“段落”对话框中,选择“换行和分页”选项卡,然后再勾选(2)。(1)
操作系统通过_________来组织和管理外存中的信息。
在Excel中,单元格L3内容为“软件工程技术”,若要取单元格L3前两个字“软件”放入单元格M3中,则可以在M3中输入(4)________________,并按下回车键即可。
Internet的基本服务,如电子邮件E-mail、远程登录Telnet、文件传输FTP与WWW浏览等,它们的应用软件系统设计中都采用了
随机试题
羁束行政行为
能对人的工作与学习产生实际效果的兴趣品质是()。
全面建设社会主义现代化国家、实现中华民族伟大复兴的重要法宝是()
酒渣鼻最常见的发病部位为
华昌有限公司有8个股东,麻某为董事长。2013年5月,公司经股东会决议,决定变更为股份公司,由公司全体股东作为发起人,发起设立华昌股份公司。下列哪些选项是正确的?(2013年卷三69题,多选)
根据《堤防工程施工规范》SL260—98,堤防工程施工严禁在堤身两侧设计规定的()内取土。
自然社区,即人类在生产和生活中自然形成的聚落,是非人为的、人们在长期生活中自然形成、共生共存的社会地理空间。其特征不包括()。
在下列存储结构中,数据结构中元素的存储地址与其关键字之间存在某种映射关系的是()。
Advancingagemeanslosingyourhair,yourwaistlineandyourmemory,right?DanaDenisisjust40yearsold,but【C1】______she’s
Whenisadriverlikelytohaveasleep-relatedaccidentaccordingtoresearchers?
最新回复
(
0
)