问题 填空题

以下程序的输出结果是______。 #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。

单项选择题
名词解释