简答题
👁️ 浏览量:

试题题干

#include″string.h″
struct worker
{  char name[15];
   int age;
   float pay;
};
main( )
{  struct worker x;
   char *t=″Lilei″;
   int d=20;float f=100;
   strcpy(x. name,t);
   x.age=d*2;x.pay=f*d;
   printf(″%s\t%d\t%.0f\n″,x.name, x.age,x.pay);

参考答案

试题解析

strcpy(x. name,t);是将字符串″Lilei″完整地复制到字符数组x. name中,字符数组的原有内容被覆盖。x.age=d*2=20*2=40;x.pay=f*d=100*20=2000,即输出的x.name, x.age,x.pay分别为Lilei,40,2000。