C 结构设置和初始化变量

C 结构设置和初始化变量,c,C,我已经提供了代码段部分,设置了结构。我明白了 设置结构时出现错误“需要表达式”。请 请参阅我提供的代码段。我已经复习了其他代码 这应该行得通 Can not compile the program with the program segment below. Not sure how to correct it. error in the .size and .char part. This part is just the code segment for the structur

我已经提供了代码段部分,设置了结构。我明白了 设置结构时出现错误“需要表达式”。请 请参阅我提供的代码段。我已经复习了其他代码 这应该行得通

 Can not compile the program with the program segment below. Not sure how 
 to correct it. error in the .size and .char part. This part is just the 
 code segment for the structure.


 #define MAX_SIZE 25  // max name size

 typedef struct     // structure for an employee name and height size
 {
    char name[MAX_SIZE];
    int size;
 } Employee;

 int main(int argc, char ** argv)
 {

  Employee student =        // initializes the structure
  {
    .name = { 0 },  // error expected an expression. 
    .size = MAX_SIZE    // error expected an expression.
  };                    // does not accept the .name and .size                           
 }

我正在使用microsoft visual studio 2017。

也许您的编译器不支持指定的初始值设定项。您使用的编译器是什么?C99引入了指定的初始值设定项。GCC 5及以上默认为C11;C90的早期版本。您应该确保至少请求对C99的支持。您的代码是完全有效的C语言。Microsoft不为C语言制作编译器。他们制作了一个C++编译器,编译一些C程序,但不是使用C++中不具有C++特性的那些程序,即使这些特性已经用了20年或更长时间。微软多次明确表示,他们无意改变这一点。