• 2022-06-09
    ​以下结构体说明和变量定义中,正确的是( )‌
    A: typedef struct abc{ int n;double m; }ABC;ABC x,y;
    B: struct abc{ int n;double m };struct abc x, y;
    C: struct ABC{ int n;double m; }struct ABC x, y;
    D: struct abc{ int n;double m; };abc x, y;
  • A

    内容

    • 0

      定义struct s {int x; char y[6];} s1;, 正确的赋值是 A: s1.y=”abc”; B: s1->y=”abc”; C: strcpy(s1.y,”abc”); D: s1.strcpy(y,”abc”);

    • 1

      以下选项中,不能定义s为合法的结构变量的是 。 A: struct abc{double a;char b[10];}s; B: struct{double a;char b[10];}s; C: struct abc{double a;char b[10];};struct abc s; D: struct s{double a;char b[10];};

    • 2

      函数f()定义如下,该函数返回值的数据类型是______。 struct ABC int a;int b;int c;; struct ABC *f(struct ABC abc[2]) return (abc);

    • 3

      以下结构体类型说明和变量定义中正确的是( )。 A: typedef struct {int n; char c;} REC;REC x,y; B: struct REC;{int n; char c;};REC x,y; C: typedef struct REC ;{int n=0; char c=’A’; } x,y; D: struct{int n; char c;} REC x,y;

    • 4

      写出下面程序的运行结果。struct abc{    int a;                     float b;                     char *c; };          int main(void)           {   struct abc x = {23,98.5,"wang"};   struct abc *px = &x;    printf("%d, %s, %.1f, %s \n", x.a, x.c, (*px).b, px->c );    return 0;}