fun函数是按照值传递进行的
fun函数是结构体数组作为参数
结构体数组做参数,属于地址传递
数组p做参数传递是数组的首地址
第1题:
下列语句段中,正确的是( )。
A.struct{int x;float y;int a[2];unsigned b[3];char name[10];};
B.struct stu{unsigned a[3];unsigned b[4];}x;int*p=&x.a;
C.struct stu{int a;float x[4];}y={1,1.0};float data=y.x;
D.struct nd{int a,b;unsigned c[2]=5;};
第2题:
有以下程序:
#include<
struct stu { int num;char name[10];int age;}
void fun(struct stu*p)
{ printf("%s\n",(*p).name);}
main
{ struct stu students[3]={{9801,"Zhang".20}, {9802,"Wang",19},{9803,"Zhao",1 8}}
fun(students+2); }
输出的结果是( )。
A.Zhang
B.Zhao
C.Wang
D.18
第3题:
( 38 )有以下定义和语句
struct workers
{ int num;char name[20];char c;
struct
{ int day; int month; int year; } s;
} ;
struct workers w,*pw;
pw = &w;
能给 w 中 year 成员赋 1980 的语句是
A ) *pw.year = 198O;
B ) w.year=1980;
C ) pw->year=1980;
D ) w.s.year=1980;
第4题:
有以下定义和语句: struct students {int num;char name[20];char c; struct {int grade1;int grade2;}s; }; struct students w,*pw; *pw=w; 下列赋值语句不正确的是( )。
A.w.num=1002;
B.w.grade1=85;
C.pw->num=1002;
D.w.s.grade2=85;
第5题:
下列对结构及其变量定义错误的是( )。
A.struct My Struct
B.struct MyStruct{ {int num; int num;char ch; char ch;} }My;
C.strut
D.struct{ {int num; int num;char ch; char ch;}My; };
第6题:
看这段程序,可是执行。#include <stdio.h>int main(int argc, char *argv[]){ struct info { char name[33]; int age; }; struct info aa[3]={"meng",20,"juan",29,"an",59}; struct info *p=aa; for(int i=0;i<3;i++,p++) printf("%-6s %d\n",p->name,p->age);}将其改成这样:#include <stdio.h>int main(int argc, char *argv[]){ struct info { char name[33]; int age; }; struct info aa[3]={"meng",20,"juan",29,"an",59}; //struct info *p=aa; for(int i=0;i<3;i++,aa++) printf("%-6s %d\n",aa->name,aa->age);}为什么就执行不了呢
第7题:
有以下程序 #include <string.h> struct STU { char name[10]; int num; }; void f(char *name, int num) { struct STU s[2]={{"SunDan",20044},{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() { struct STU s[2]={{"YangSan",20041},{"LiSiGuo",20042}},*p; p=&s[1]; f(p->name,p->num); printf("%s %d\n",p->name,p->num); } 程序运行后的输出结果是
A.SunDan 20042
B.SunDan 20044
C.LiSiGuo 20042
D.YangSan 20041
第8题:
设有定义:
struct person
{ int ID;char name[12];}p;
请将 scanf("%d", 【 1 2 】 ); 语句补充完整,使其能够为结构体变量 p 的成员 ID 正确读入数据。
第9题:
有以下程序: #include <string.h> struct STU (char name[10]; int num; }; void f(char *name, int num) {struct STU s[2]={{"SunDan",20044}.{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() {struct STU s[2]={{"YangSall",20041},{"LiSiGao",20042}},*p;p=&s[1]; f(p->name,p->num); printf("%s%d\n",p->name,p->num); } 程序运行后的输出结果是 ______。
A.SunDan 20042
B.SunDan 20044
C.LiSiGuo 20042
D.YangSan 20041
第10题:
设有定义:
struct person
{int ID;char name[12];}P;
请将scanf(“%d”, 【 】);语句补充完整,使其能够为结构体变量P的成员ID正确读人数据。