title: C: structs, arrays with month and day input
body: <p>I am working on a program, that when a user enters a month number and day number, the program will print out the month and number of days (year to date). For example, if the user enters 12 30, the program will print December (DEC) 30 means 364 days YTD. The program does not need to worry about leap years. I have posted the code below. My program does not work and I am not sure why. I think my issue comes with trying to pull the month number and name from the struct month months, but I am not sure. I am using MSVS and when I try to use the debugger, I get the warnings about the errors and am told to "run for the last successful build" (there isn't one). </p>
  
  <p>I get the following errors:</p>
  
  <ol>
  <li>"type name is not allowed" on lines 55, 57, 58</li>
  <li>'month': illegal use of this type as an expression   on lines 55, 57, 58</li>
  <li><p>left of '.abbrev'/'.months'/'.monumb' must have class/struct/union   on lines 55, 57, 58</p>
  
  <pre><code> #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int finddata(int month, int days);
  
  struct month 
  {
      char name[10];
      char abbrev[4];
      int days;
      int monumb;
  };
  
  struct month months[12] =
  {
      { "January", "jan", 31, 1 },
      { "February", "feb", 28, 2 },
      { "March", "mar", 31, 3 },
      { "April", "apr", 30, 4 },
      { "May", "may", 31, 5 },
      { "June", "jun", 30, 6 },
      { "July", "jul", 31, 7 },
      { "August", "aug", 31, 8 },
      { "September", "sep", 30, 9 },
      { "October", "oct", 31, 10 },
      { "November", "nov", 30, 11 },
      { "December", "dec", 31, 12 }
  };
  
  int main()
  {
      struct month userdata;
  
      do
      {
          printf("Enter month and day number:");
  
          scanf_s("%d %d", &amp;userdata.monumb, &amp;userdata.days);
  
          finddata(userdata.monumb, userdata.days);
  
      } while ((userdata.monumb &gt; 0) &amp;&amp; (userdata.monumb &lt; 13));
  
  
      return 0; 
  }
  
  
  
  int finddata(int months, int days)
  {
      int i;
      int total = 0;
  
      for (i = 1; i != month.monumb[i]; i++) //**(line 55)**
      {
          puts(month.name[i]); //**(line 57)**
          puts(month.abbrev[i]); //**(line 58)**
      }
      printf("%d means", months);
  
      if (months == 1)
      {
          total = days;
      }
      else if (months == 2)
      {
          total = days + 31;
      }
      else if (months == 3)
      {
          total = 31 + 28 + days;
      }
      else if (months == 4)
      {
          total = 31 + 28 + 31 + days;
      }
      else if (months == 5)
      {
          total = 31 + 28 + 31 + 30 + days;
      }
      else if (months == 6)
      {
          total = 31 + 28 + 31 + 30 + 31 + days;
      }
      else if (months == 7)
      {
          total = (31 * 3) + 28 + (30 * 2) + days;
      }
      else if (months == 8)
      {
          total = (31 * 4) + 28 + (30 * 2) + days;
      }
      else if (months == 9)
      {
          total = (31 * 5) + 28 + (30 * 2) + days;
      }
      else if (months == 10)
      {
          total = (31 * 5) + 28 + (30 * 3) + days;
      }
      else if (months == 11)
      {
          total = (31 * 6) + 28 + (30 * 3) + days;
      }
      else if (months == 12)
      {
          total = (31 * 6) + 28 + (30 * 4) + days;
      }
      else
      {
          //blank
      }
  
      printf("%d days YTD.", total);
  
      return 0;
  }
  </code></pre></li>
  </ol>