根据程序,请判断输出结果:#include<stdio.h>struct stu{int num;char name[5];int age;char sex;};void fun(struct stu *p){printf("%s\n",(*p).name);}main(){struct stu stud[3]={{0001,"zhang",20,'f'},{0002,"li",18,'m'},{0003,"chen",19,'f'}};fun(stud+2);}
举一反三
- 以下程序的运行结果是( ) #include struct s { int num; char name[20]; int age; }; fun(struct s *p) { printf("%s ",(*p).name); } void main( ) { struct s stud[3]={{101,"Li",18},{102,"Wang",19},{103,"Zhang",21}}; fun(stud+2); } A: Li B: Wang C: Zhang D: 不确定的值
- 以下结构体的定义语句中,正确的是______。? struct student {int num; char name[10];int age;}stu;|struct {int num; char name[10];int age;}student; struct student stu;|struct student {int num; char name[10]; int age;}; student stu;|struct student {int num; char name[10];int age;};stu;
- 有以下程序段,输出结果为()。 #include<stdio.h> struct student {int num; char name[20]; float score; }; main() {struct student stu[5]; printf("%d",sizeof(stu)); }
- 下列程序的输出结果第一行是_____,第二行是_______。 #include [iostream] #include [cstring] #include [iomanip] using namespace std; struct student { int num; char name[20]; double score; }; void fun(struct student *s); int main() { struct student stu={12345, "Zhangwei", 98.0}; cout[<stu.num<<","<<stu.name<<","<<stu.score<<endl; fun(&stu); cout<<stu.num<<","<<stu.name<<","<<stu.score<<endl; return 0; } void fun(struct student *s) { s-]num=23456; strcpy(s->name, "Liming"); s->score=88; }
- 对结构体类型变量定义不正确的是( )。 A: B: define STUDENT struct studentSTUDENT{char name;int num;}std; C: struct student{char name;int num;}stu; D: E: define struct student{char name;int num;}STD;STD stu; F: struct{char name;int num;}student;struct student stu;