首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
以下程序的输出结果是( )。 #include<stdlib.h> main() {char*s1,*s2,m; s1=s2=(char*)malloc(sizeof(char)); *s1=15; *s2=2
以下程序的输出结果是( )。 #include<stdlib.h> main() {char*s1,*s2,m; s1=s2=(char*)malloc(sizeof(char)); *s1=15; *s2=2
admin
2011-06-13
63
问题
以下程序的输出结果是( )。
#include<stdlib.h>
main()
{char*s1,*s2,m;
s1=s2=(char*)malloc(sizeof(char));
*s1=15;
*s2=20;
m=*s1+*s2:
printf("%d\n",m);
}
选项
答案
40
解析
malloc()函数的作用是开辟一个长度为sizeof(char)的内存区,s1、s2为指向字符型数据的指针变量,执行“s1=s2=(char*)malloc(sizeof(chat));”语句后,s1、s2指向同一个存储空间,此时m=*s1+*s2=20+20=40。
转载请注明原文地址:https://kaotiyun.com/show/mVPp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序:main(){inta[3][3],*p,i;p=&a[0][0];for(i=0;i<9;i++)p[i]=i+1;printf("%d\n",a[1][2]);}
设有定义:intn1=0.n2,*p=&n2,*q=&n1;,以下赋值语句中与n2=n1;语句等价的是
以下程序的输出结果是charcchar(charch){if(ch>=’A’&&ch<=’Z’)ch=ch-’A’+’a’;returnch;}main(){cha
请选出可用作C语言用户标识符的是()。
有以下程序段intn,t=1,s=0;scanf("%d",&n);do{s=s+t;t=t-2;}while(t!=n);为使此程序段不陷入死循环,从键盘输入的数据应该是
下列选项中正确的语句是
下列关于单目运算符++、--的叙述中正确的是
下面的描述中,符合结构化程序设计风格的是()。
已有定义如下:structnode{intdata;structnode*next;}*p;以下语句调用malloc函数,使指针p指向一个具有structnode类型的动态存储空间。请填空。
“商品”与“顾客”两个实体集之间的联系一般是()。
随机试题
NowthatwearefairlysurethattherearemanyEarth-likeplanetsintheGalaxy,thetimeisripe(oralmostso)towonderwhet
关于社会主义法治理念,下列哪些选项是正确的?(2007年试卷一第51题)
下列关于信用风险预期损失的说法,不正确的是()。
下列辽宁省的风景区中,属于国家级风景名胜区的有()。
如果当事人要求向法院提起诉讼,人民调解委员会应当()。
第3代计算机采用的电子元件是
Morethan30,000driversandpassengerswhositinthefrontofthevehiclesarekilledorseriouslyinjuredeachyear.Atasp
Howlongdoesittakefromheretoyourhomeonfoot?
FamilyMattersThismonth,Wyomingpassedabillthatwouldgivelegalteethtothemoralobligationtosupportone’sparents.C
Self-esteemisaprivate,individualmatter.Itgoesupanddownfromdaytoday,orevenfromhourtohour.Thus,strengthening
最新回复
(
0
)