首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序 #include #include struct S { char name[10]; }; void change(struct S *data, int value) { strcpy(data->name, "****"); valu
有如下程序 #include #include struct S { char name[10]; }; void change(struct S *data, int value) { strcpy(data->name, "****"); valu
admin
2015-07-28
51
问题
有如下程序
#include
#include
struct S
{
char name[10];
};
void change(struct S *data, int value)
{
strcpy(data->name, "****");
value = 13;
}
main()
{
struct S input;
int num = 4;
strcpy(input.name, "THIS");
change(&input, num);
printf("%s,%d\n", input.name, num);
}
程序运行后的输出结果是( )。
选项
A、****,4
B、****,13
C、THIS,4
D、THIS,13
答案
A
解析
函数change()的第一个参数为结构体变量地址作为函数参数,为地址传参,形参和实参指向的为同一块内存地址,所以对数组元素的改变能够影响到实参。语句"strcpy(data->name, "**** ");"则将data指向的结构体变量中的name值变为"****";函数change()的第二个参数为值传参,所以对num的值没有改变,输出结果为4,答案选A。
转载请注明原文地址:https://www.kaotiyun.com/show/BKJp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下列程序的输出结果是_______。#defineA100main(){inti=0,sum=0;do{if(i==(i/2)*2)continue;sum+=i;}whil
若整型变量a、b、c、d中的值依次为:1、4、3、2。则条件表达式a<b?a:c<d?c:d的值是______。
以下程序的输出的结果是______。intx=3;main(){inti;for(i=1;i<x;i++)incre();}incre(){staicintx=1
以下程序的输出结果是______。 int f() { static int i=0; int s=1; s+=i;i++; return s; } main() { int i,a=0; for(i=0;i<5;i++)a+=f(): printf("%
以下程序的运行结果是______。main(){chara=-10;unsignedcharb=10;printf("%d,%d",a>>2,b>>2);}
以下程序的输出结果是______。 #include <string.h> main() { char*a="abcdefghi";int k fun(a);puts(a); } fun(char*s) { int x,y; char c for(x=0,
执行下面程序段的结果是______。 int x=234; do { printf("%3d\n",x--); } while(!x);
Tubro C中long int类型变量所占的字节数是______。
以下叙述正确的是
随机试题
钙离子、镁离子的存在会使管线结垢。()
高选择性胃迷走神经切断术的要点是()(1991年)
A、惊厥B、帕金森病C、抑郁症D、痛风E、记忆障碍硫酸镁用于治疗
下列股票交易行为中,属于国家有关证券法律、法规禁止的有( )。
当事人提交给法院的以下材料中,不属于民事诉讼证据的有()。
同一借款人对本行或其他银行的部分债务已经不良时,其贷款至少可以归为()。
具有下列哪种情形,男方可以提出离婚?()。
1951年至1952年开展的“三反”运动的内容是( )
A、It’s6:00a.m.B、It’ssnowing.C、I’dliketodrink.B
Ourbodiesexperienceanebbandflowofenergythroughouttheday.Thisiscalledacircadianrhythm,andithasbeenstudied【C
最新回复
(
0
)