title: C Program ERROR 2440/2447 in my code works on online commpiler but not in visual studios 2019
body: <p>my program works on all online compilers but not on visual studios. However whenever I try to run it on visual studios 2019, it doesn't run and gives me 2 errors. error2440 and error2447. I have tried to fix it but nothing seems to work if anyone has any idea on what to do it would be appreciated the code:</p>
  <p>EDIT: after putting const in front of char I did not get any errors but I did get multiple warnings. the warnings are:</p>
  <p>warning C4101: 'year': unreferenced local variable
  warning C4101: 't': unreferenced local variable
  warning C4101: 'r': unreferenced local variable
  warning C4101: 'weekdays': unreferenced local variable
  warning C4101: 'leapyear': unreferenced local variable
  error C4700: uninitialized local variable 'year' used
  error C4700: uninitialized local variable 'firstday' used
  error C4700: uninitialized local variable 'p' used
  error C4716: 'printday': must return a value
  error C4700: uninitialized local variable 'year' used</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
  int month_days[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
  char* month_name[] =
  {
  &quot; &quot;,
  &quot;\n\n\n\t\t1&quot;,
  &quot;\n\n\n\t\t2&quot;,
  &quot;\n\n\n\t\t3&quot;,
  &quot;\n\n\n\t\t4&quot;,
  &quot;\n\n\n\t\t5&quot;,
  &quot;\n\n\n\t\t6&quot;,
  &quot;\n\n\n\t\t7&quot;,
  &quot;\n\n\n\t\t8&quot;,
  &quot;\n\n\n\t\t9&quot;,
  &quot;\n\n\n\t\t10&quot;,
  &quot;\n\n\n\t\t11&quot;,
  &quot;\n\n\n\t\t12&quot;
  };
  int get_first_start_day(int year)
  {
  int start_day;
  int x, y, z;
  
  x = (year - 1) / 4;
  y = (year - 1) / 100;
  z = (year - 1) / 400;
  start_day = (year + x - y + z) % 7;
  return start_day;
  }
  
  void set_feb_days(int year)
  {
  if (year % 4 == 0 &amp;&amp; year % 100 != 0 || year % 400 == 0)
      month_days[2] = 29;
  else
      month_days[2] = 28;
  }
  
  void display_month_calendar(int days, int start_day)
  {
  int month, year;
  for (month = 1; month &lt;= 12; month++)
  {
      printf(&quot;%s&quot;, month_name[month]);
      printf(&quot;\n\nSun  Mon  Tue  Wed  Thu  Fri  Sat\n&quot;);
  
      for (days = 1; days &lt;= 1 + start_day * 5; days++)
      {
          printf(&quot; &quot;);
      }
      for (days = 1; days &lt;= month_days[month]; days++)
      {
          printf(&quot;%2d&quot;, days);
          if ((days + start_day) % 7 &gt; 0)
              printf(&quot;   &quot;);
          else
              printf(&quot;\n &quot;);
      }
      start_day = (start_day + month_days[month]) % 7;
    }
  }
  int printday(void)
  {
  int month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  char week[7][10];
  int date, mon, year, i, t, r, s = 0;
  strcpy(week[0], &quot;Sunday&quot;);
  strcpy(week[1], &quot;Monday&quot;);
  strcpy(week[2], &quot;Tuesday&quot;);
  strcpy(week[3], &quot;Wednesday&quot;);
  strcpy(week[4], &quot;Thursday&quot;);
  strcpy(week[5], &quot;Friday&quot;);
  strcpy(week[6], &quot;Saturday&quot;);
  printf(&quot;Please Enter the date and month:  &quot;);
  scanf(&quot;%d%d&quot;, &amp;date, &amp;mon);
  if ((year % 400 == 0) || ((year % 4 == 0) &amp;&amp; (year % 100 != 0)))
      month[1] = 29;
  for (i = 0; i &lt; mon - 1; i++)
      s = s + month[i];
  s = s + (date + year + (year / 4) - 2);
  s = s % 7;
  printf(&quot;\n%d/%d is a %s\n&quot;, date, mon, week[s]);
  }
  void occurrenceDays(int p, char firstday)
  {
  int year;
  int monthdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  firstday = get_first_start_day(year);
  char days[7][10];
  strcpy(days[0], &quot;Sunday&quot;);
  strcpy(days[1], &quot;Monday&quot;);
  strcpy(days[2], &quot;Tuesday&quot;);
  strcpy(days[3], &quot;Wednesday&quot;);
  strcpy(days[4], &quot;Thursday&quot;);
  strcpy(days[5], &quot;Friday&quot;);
  strcpy(days[6], &quot;Saturday&quot;);
  int count[7];
  for (int i = 0; i &lt; 7; i++)
      count[i] = 4;
  int pos;
  for (int i = 0; i &lt; 7; i++)
  {
      if (firstday == days[i][10])
      {
          pos = i;
          break;
      }
  }
  int inc = monthdays[p] - 28;
  for (int i = pos; i &lt; pos + inc; i++)
  {
      if (i &gt; 6)
          count[i % 7] = 5;
      else
          count[i] = 5;
  }
  int weekdays = monthdays[p] - count[0] - count[6];
  printf(&quot;Their are %d sundays,%d Saturdays and %d weekdys in the month\n&quot;, count[0], count[6], 
  weekdays);
  }
  
  int main(void)
  {
  int year, start_day, leapyear, t, p, firstday, weekdays;
  int month;
  printf(&quot;Please Enter a Four Digit Year : &quot;);
  scanf(&quot;%d&quot;, &amp;year);
  start_day = get_first_start_day(year);
  set_feb_days(year);
  display_month_calendar(year, start_day);
  printf(&quot;\n&quot;);
  printf(&quot;Please Enter the Starting Day of the year (1=Sun, 7=Sat): 6 &quot;);
  printf(&quot;Please enter the month : &quot;);
  scanf(&quot;%d&quot;, &amp;month);
  occurrenceDays(p, firstday);
  printday();
  printf(&quot;Do you want to try it again?(1 to continue/0 to quit) :&quot;);
  scanf(&quot;%d&quot;, &amp;t);
  while (t &gt;= 0)
  {
      if (t == 1)
      {
          printday();
          printf(&quot;Do you want to try it again?(1 to continue/0 to quit) :&quot;);
          scanf(&quot;%d&quot;, &amp;t);
      }
      else
      {
      }
      break;
  }
  return 0;
  }
  </code></pre>
  <p>however my error is here:</p>
  <pre><code>{
  &quot; &quot;,
  &quot;\n\n\n\t\t1&quot;,
  &quot;\n\n\n\t\t2&quot;,
  &quot;\n\n\n\t\t3&quot;,
  &quot;\n\n\n\t\t4&quot;,
  &quot;\n\n\n\t\t5&quot;,
  &quot;\n\n\n\t\t6&quot;,
  &quot;\n\n\n\t\t7&quot;,
  &quot;\n\n\n\t\t8&quot;,
  &quot;\n\n\n\t\t9&quot;,
  &quot;\n\n\n\t\t10&quot;,
  &quot;\n\n\n\t\t11&quot;,
  &quot;\n\n\n\t\t12&quot;
  };
  </code></pre>
  <p>thank you for any help in advance</p>