首页/ 题库 / [单选题]有以下程序:#include <stdi的答案

有以下程序:#include <stdio.h>#include <strine.h> struct STU { char name[10]; int hum;};void f(char * name,iht num){ struct STU s[2] = {{ "SunDan" ,20044} , {" Penghua" ,20045}}; num= s[0]. nnm; strepy(name,s[0], name);}main( ){ struct STU s[2] = {{"YangSan" ,20041 }, { "LiSiGao" ,20042}}, * P; p = &s[1]; f(p->name,p->hum); printf("% s %d " ,p-> name,p->num);}程序运行后的输出结果是( )。

单选题
2022-05-21 01:25
A、SunDan 20042
B、SunDan 20044
C、LiSiGuo 20042
D、YangSan 20041
查看答案

正确答案
A

试题解析
解析:main函数中将定义的结构体类型指针变量p指向结构体类型数组s[1],通过调用函数f改变了指针变量p所指向的结构体中成员变量name的值,但并未改变其num的值。这是因为函数f中的形参name是一个字符型指针变量,它指向了main函数中指针变量p所指向的结构体的成员变量name,所以对函数f中的形参*name的改变也就对main函数中p->name的改变,而函数f中对形参num的改变不会影响main函数中p-?num的值,因为此时传递给num的是一个值,而不是地址。

标签:
感兴趣题目
有以下程序:#include <stdio.h>#include <strine.h> struct STU { char name[10]; int hum;};void f(char * name,iht num){ struct STU s[2] = {{ "SunDan" ,20044} , {" Penghua" ,20045}}; num= s[0]. nnm; strepy(name,s[0], name);}main( ){ struct STU s[2] = {{"YangSan" ,20041 }, { "LiSiGao" ,20042}}, * P; p = &s[1]; f(p->name,p->hum); printf("% s %d " ,p-> name,p->num);}程序运行后的输出结果是( )。
有以下程序: #include <stdio.h> main( ) { int a=7; while(a--); print[("%d ",a); } 程序运行后的输出结果是( )。
有以下程序: #include <stdio, h> main( ) { int m =0256,n =256; printf( "% o % o " ,m,n); 程序运行后的输出结果是( ) 。
有以下程序: #include <stdio.h> struct s { int x,y;} data[2]={10,100,20,200}; main() { struct s *p=data; printf("%d ",++(p->x)); 程序运行后的输出结果是( )。
下列程序的输出结果是( )。 #include<stdio.h> #include<string.h> main() { char a[]=" 123\"; printf("%d,%d ",strlen(a),sizeof(a)); }
以下程序的输出结果是_______。 #include<stdio.h> main() { printf("%d ",NULL); }
以下程序的输出结果是( )。 #include<stdio.h> main() { printf("%d ",NULL); }
有以下程序段 #include<stdio.h> main( ) { . . .while(getchar( )!=\n); . . . } 以下叙述中正确的是( )。
有以下程序: #include<stdio.h> main( ) {int X=011; printf("%d ",++x); } 程序运行后的输出结果是( )。
有以下程序:
#include<stdio.h>
#include<string.h>
main(  )
{printf{"%d",strlen("%d",strlen("ATS0121"));}   
程序运行后的输出结果是(  )。
有以下程序: #include <stdio.h> #include <string.h> main() { char str[][20]={"Hello","Beijing"},*P=str[0]; printf("%d ",strlen(p+20)); } 程序运行后的输出结果是( )。
以下程序: #include<stdio.h> #include<string.h> main() {char str[]="abcd 123xab"; printf("%d",(str)); } 运行后的输出结果是( )。
相关题目
有以下程序 #include <stdio .h> main () { printf("%d ", NULL); }
以下程序的运行结果是 ( ) #definePI 3.141593 #include<stdio.h> main( ) { printf("PI=%fn",PI); }
有以下程序: #include<stdio.h> main() { printf("%d ",NULL);} 程序运行后的输出结果是( )。
有以下程序: #include <stdio.h> main() { printf("%d ",NULL)"} 程序运行后的输出结果是( )。
有以下程序#include <stdio.h>main( ){ printf("%d\n",NULL); }程序运行后的输出结果是
有以下程序: #include<stdio.h> main() {printf("%d ",NULL)); 程序运行后的输出结果是( )。
有以下程序 #include<stdio.h> struct ord { int x,y;} dt[2]={1,2,3,4}; mare() { struct ord*p=dt; printf("%d,",++p->x); printf("%d ",++p->y); } 程序的运行结果是______。
以下程序的运行结果是( )。 #include <stdio.h> main() { st,uct date {int year,month,day;}today; printf("%d ",sizeof(struct date)); }
有以下程序:#include main(){ int sum=0,x=5; do{ sum+=x; } while(!--x); printf(%d,sum);}程序的运行结果是(  )。
以下程序的输出结果是 ( ) #include<stdio.h> main() {struct stru{int a,b: char c[6]; }: printf("%d ",sizeof(stru)), }
有以下程序:#include main(){ int x=011; printf(%d,++x);}程序运行后的输出结果是(  )。
有以下程序(其中k的初值为八进制数):#include main(){ int k=011; printf(%d,k++);}程序运行后的输出结果是(  )。
有以下程序:#include main(){ char s[10] = verygood, *ps = s; ps += 4; ps = nice; puts(s);}程序的运行结果是(  )。
有以下程序:#include #include main(){ char a[20]=ab,b[20]=cdef; int k=0; strcat(a,b); while(a[k]!='\0') {  b[k]=a[k];  k++; } puts(b);}程序的运行结果是(  )。
有以下程序:#include#includemain(){ char w[20],a[5][10]={abcdef,ghijkl,mnopq,rstuv,wxyz.}; int i; for(i=0;i<5;i++)w[i]=a[i][strlen(a[i])-1]; w[5]='\0'; puts(w);}程序的运行结果是(  )。
有以下函数:#include main(){ int a=12,c; c=(a<<2)<<1; printf(%d,c);}程序运行后的输出结果是(  )。
有以下程序:#include main(){ int a=3; int b=3; printf(%d, a&b);}程序运行后的输出结果是(  )。
有以下程序:#includestruct S{int a;int *b;};main(){ int x1[] = {3,4},x2[] = {6,7}; struct S x[] = {1,x1,2,x2}; printf(%d,%d,*x[0].b,*x[1].b);}程序的运行结果是(  )。
有以下程序#include main(){ int i=1; i=i^i; printf(%d,i);}程序运行后的输出结果是(  )。
有以下程序:#include #include #include main(){ char*p1,*p2; p1=p2=(char*)malloc(sizeof(char)*10); strcpy(p1,malloc); strcpy(p2,p1+1); printf(%c%c, p1[0], p2[0]);}程序的运行结果是(  )。
广告位招租WX:84302438

免费的网站请分享给朋友吧