C常见问题之结构的声明和变量

2013-11-20 14:17:42 · 作者: · 浏览: 155

  不使用typedef的情况:

  有如下两种定义结构变量x的方式:

  [cpp]

  struct str{

  int a;

  double b;

  };

  struct str x;

  [cpp]

  struct str{

  int a;

  double b;

  }x;

  使用typedef的情况:

  有如下两种定义结构变量x的方式:

  [cpp]

  typedef struct str{

  int a;

  double b;

  }STR;

  STR x;

  [cpp]

  typedef struct{

  int a;

  double b;

  }STR;

  STR x;