C语言---结构体成员变量加“点”赋值

来源:互联网 发布:五个金冠的淘宝店铺名 编辑:程序博客网 时间:2024/05/20 14:20
结构体成员变量加“点”赋值
#include <stdio.h>    typedef struct _led  {      int ver;      char name[10];  }LED;    int main(void)  {      int i;        LED leds[]={              {              .ver=3,              .name="led3",              },                {              .ver=4,              .name="led4",              },                };      for(i = 0; i < 2; i++)      {          printf("%d----%s\n",leds[i].ver,leds[i].name);      }         return 0;  }  


1. 文件保存为test.c

2.运行:

gcc test.c -o test

./test

3.结果:

3----led3

4----led4

4.结论:

以上结构体赋值遵循C99标准,VC下就不支持