小编use*_*512的帖子

请在这里解释typedef的行为

int main()
{
  int a;
  typedef struct  
  {
      int i;
      int j;
  }type1;
  typedef type1 type[10]; //Please explain this line ?
  typedef struct 
  {
      int  l;
      type  c;
  }type2;

  type2 x;
  x.c[0].i=1;   //How can we write this??
  x.c[0].j=2;

  x.c[2].j=3;

  printf("%d",x.c[2].j);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

程序正在成功编译,我正在考虑不要因为

    typedef type1 type[10];
Run Code Online (Sandbox Code Playgroud)

请解释这里打字的行为.我所知道的是我们可以在typedef的帮助下定义一个别名.

输出:3

c typedef structure

4
推荐指数
1
解决办法
155
查看次数

标签 统计

c ×1

structure ×1

typedef ×1