以下程序的运行结果是( ) #include struct student { int num; char name[20]; float score; }stu1={1002,"liling",98.5}; void main( ) { struct student *p; p= printf("%s\n",p-name); }
A: 1002
B: liling
C: 98.5
D: 不确定的值
A: 1002
B: liling
C: 98.5
D: 不确定的值
举一反三
- 有以下程序段,输出结果为()。 #include<stdio.h> struct student {int num; char name[20]; float score; }; main() {struct student stu[5]; printf("%d",sizeof(stu)); }
- 有以下程序段,输出结果为()。#include<stdio.h>struct student{int num;char name[20];float score;};main(){struct student stu[5];printf("%d",sizeof(stu));} A: 140 B: 160 C: 5 D: 随机值
- 以下程序的运行结果是( ) #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: 不确定的值
- 下列程序的输出结果第一行是_____,第二行是_______。 #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: struct student{int num, char name[20];} s; B: struct {int num, char name[20];} s; C: struct student{int num, char name[20];}; struct student s; D: struct student{int num, char name[20];} ; student s