有以下程序 #include <stdio.h> #include <string.h> struct computer { char CPU[10]; }; main( ) { struct computer pc1, p

admin2021-06-15  28

问题 有以下程序
#include   <stdio.h>
#include   <string.h>
struct  computer
{    char  CPU[10];   };
main( )
{
    struct computer  pc1, pc2;
    strcpy(pc1.CPU, "3.2G");
    strcpy(pc2.CPU, "????");
    pc1 = pc2;
    printf("%s\n", pc1.CPU);
}
程序运行后的输出结果是

选项 A、?
B、3.2G
C、????
D、?.2G

答案C

解析 二个类型相同的结构体,可以使用一个给另一个初始化,使它们相等。前提是右值结构体变量所有成员全部初始化了。pc1=pc2,pc2的成员值和pc1中对应的成员相等。因此pc1.CPU输出????。答案为C选项。
转载请注明原文地址:https://jikaoti.com/ti/3Lz0FFFM
0

相关试题推荐
最新回复(0)