结构设置和初始化变量

时间:2019-10-02 21:38:40

标签: 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 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                           
 }

1 个答案:

答案 0 :(得分:0)

我正在使用Microsoft Visual Studio 2017。