title: Problem with reading from a file and put information into struct in C (different var in struct, return error, non-nested function with var modif type)
body: <p>I want to write a program, which will read from a text file and put information into struct. In struct I have the name of an element (which is char array), a symbol of an element (V - vector, S - scalar, M - array), dimension and value. Later I will write this struct into another file.
  This is my file</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;assert.h&gt;
  
  int main (int argc, char *argv[])
  {    
      FILE *wz, *wc;  
      int dimension, dimensionX, dimensionY;
  
      if (argc != 3) {                                
      printf(&quot;Wrong arguments number\n&quot;);
      printf(&quot;I should run this way:\n&quot;);
      printf(&quot;%s source\n&quot;,argv[0]);
      exit(1);
      }
      
      if( (wz= fopen(argv[1],&quot;r&quot;)) == NULL) {
          printf(&quot;Open error %s\n&quot;, argv[1]);
          exit(1);
      }
      if( (wc= fopen(argv[2], &quot;w&quot;)) == NULL) {
      printf(&quot;Open error %s\n&quot;, argv[2]);
      exit(2);
      }
      
      struct Vector 
      { 
          char keyWord;
          char elementName[20];
          int dimension;
          double V[dimension];
      };
      typedef struct Vector wek;
  
      struct Scalar 
      { 
          char keyWord;
          char elementName[20];
          double wartosc;
      };
      typedef struct Scalar ska;
  
      struct Array
      {
          char keyWord;
          char elementName[20];
          int dimensionX;
          int dimensionY;
          double M[dimensionX][dimensionY];
      };
      typedef struct Array mac;
  
              
      
      struct Vector w1, w2;
      struct Scalar s1, s2;
      struct Array m1, m2;
      
      
      wek readVector(FILE *wz);
  {
      wek w;
      fscanf(wz, &quot;%30s&quot;, &amp;w.keyWord);
      fscanf(wz, &quot;%30s&quot;, &amp;w.elementName[0]);
      for (int j = 0; j &lt; dimension; ++j)
              fscanf(wz, &quot;%10lf&quot;, &amp;w.V[j]);
      return w;
  }
      ska readScalar(FILE *wz);
  {
      ska s;
      fscanf(wz, &quot;%30s&quot;, &amp;s.keyWord);
      fscanf(wz, &quot;%30s&quot;, &amp;s.elementName[0]);
      fscanf(wz, &quot;%10lf&quot;, &amp;s.wartosc);
      return s;
  }
      mac readArray(FILE *wz)
  {
      mac m;
      fscanf(wz, &quot;%30s&quot;, &amp;m.keyWord);
      fscanf(wz, &quot;%30s&quot;, &amp;m.elementName[0]);
      for (int i = 0; i &lt; m.dimensionX; ++i)
          for (int j = 0; j &lt; m.dimensionY; ++j)
              fscanf(wz, &quot;%10lf&quot;, &amp;m.M[i][j]);
      return m;
  }
      s1 = readScalar(wz);
      s2 = readScalar(wz);
      w1 = readVector(wz);
      w2 = readVector(wz);
      m1 = readArray(wz);
      m2 = readArray(wz);
      fclose(wz);
      fclose(wc);
      
      return 0;
  }
  
  </code></pre>
  <p>This is my text file</p>
  <pre><code>S scalar1 3
  S scalar2 5
  V vector1 3
  2 4 7
  V vector2 3
  3 6 1
  M array_A 3 3
  1 2 3
  4 5 6
  7 8 9
  M array_B 3 3
  9 8 7
  6 5 4
  3 2 1
  </code></pre>
  <p>I get errors</p>
  <pre><code>primal.c: In function ‘main’:
  primal.c:60:9: error: non-nested function with variably modified type
       wek readVector(FILE *wz);
           ^~~~~~~~~~
  primal.c:67:12: error: incompatible types when returning type ‘wek {aka struct Vector}’ but ‘int’ was expected
       return w;
              ^
  primal.c:75:12: error: incompatible types when returning type ‘ska {aka struct Scalar}’ but ‘int’ was expected
       return s;
              ^
  
  </code></pre>