首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include<stdio.h> #include<stdlib.h> void fun(double*p1,double*p2, double*s) { s=(double*)calloc(1,
有以下程序: #include<stdio.h> #include<stdlib.h> void fun(double*p1,double*p2, double*s) { s=(double*)calloc(1,
admin
2019-02-02
63
问题
有以下程序:
#include<stdio.h>
#include<stdlib.h>
void fun(double*p1,double*p2,
double*s)
{
s=(double*)calloc(1,sizeof(double));
*s=*p1+*(p2+1);
}
main()
{
double a[2]={1.1,2.2),b[2]={10.0,20.0},*s=a;
fun(a,b,s);
printf("%5.2f\n",*s);
}
程序的输出结果是( )。
选项
A、11.10
B、1.10
C、12.10
D、21.10
答案
B
解析
函数fun()的功能是用calloc()函数重新分配了1个长度为sizeof(double)的连续空间,并把返回的内存地址赋值给s,之后往新分配的内存中写入数据。由于函数传递过程中形参指针指向的变化不能影响到实参指针的指向,所以函数fun()并不能改变s的指向,*s与a[0]等价,格式输出的结果为1.10,答案选B。
转载请注明原文地址:https://kaotiyun.com/show/hbRp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下列程序的功能是将字符串s中所有的字符c删除。请填空。#include<stdio.h>main(){chars[80];inti,j;gets(s);
有以下程序 #include<stdio.h> void WriteStr(char*fn,char*str) {FILE*fp; fp=fopen(fn"w");fputs(str,fp);fclose(fp); }
请选出以下程序的输出结果()。#include<stdio.h>sub(int*s,inty){staticintt=3;y=s[t];t--;}main(){int
在计算机中,算法是指______。
C语言规定,在一个源程序中,main函数的位置()。
以下叙述中正确的是
若有如下程序:intsub(){staticintn=1;intx=1;x*=n;n++;returnx;}main(){intn,t=1;for(n=1;n<6;n++)
下列表达式中,可以正确表示x≤0或x≥1的关系是()。
下列选项中不会引起二义性的宏定义是()。
下列实体类型的联系中,属于一对多联系的是()。
随机试题
有形展示会影响消费者和顾客,从构成因素的角度对有形展示进行划分,可分为的因素类型有_______。
下列关于钻孔桩施工时的清孔做法,叙述正确的有()。
邮局经办的报刊发行业务主要采取()方式。
中国农业银行的前身是()年成立的农业合作银行。
Ofallthe12Chinesezodiacanimals,the【E1】______istheanimalthatthepeoplefeelthegreatestconnectionto.Eventhou
血浆包括各种矿物质、糖类、脂类、蛋白质、激素和维生素等。在上述各种物质巾,造成血液颜色为红色的是:
RonaldP.RohneroftheUniversityofConnecticuthasspentsomeyearslookingattheconsequencesforchildrenandteenagersof
耦合和内聚是评价模块独立性的两个主要标准,其中反映了模块内各成分之间联系的是【】。
Thosewithspecializedtrainingtendtowithdrawfromthelaborforceearlierthanthatwithgeneraleducation—perhapsbecause
A、Theextentofdamagetothenervoussystem.B、Thepresenceorabsenceofcertainnerve-cellreceptors.C、Thesizeofnerve-cel
最新回复
(
0
)