title: updating struct variable in function
body: <p>Hello I would like to ask why my function does not update votes for candidates.
  For example I vote for Bob 3 times and than my program prints that Bob has 0 votes.</p>
  <p>Function:</p>
  <pre><code>bool check_vote(char vote_name [])
  {
      for (int i = 0; i &lt; candidate_count; i++)
      {
          if (strcmp(candidates[i].name, vote_name) == 0)
          {
              candidates[i].votes++;
              return true;
          }
      }
      return false;
  }
  </code></pre>
  <p>Whole code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdbool.h&gt;
  
  bool check_vote(char vote_name []);
  
  int candidate_count = 3;
  
  struct person
  {
      char name[50];
      int votes;
  }candidates[3];
  
  
  int main(void)
  {
      strcpy(candidates[0].name, &quot;Alice&quot;);
      candidates[0].votes = 0;
  
      strcpy(candidates[1].name, &quot;Charlie&quot;);
      candidates[1].votes = 0;
  
      strcpy(candidates[2].name, &quot;Bob&quot;);
      candidates[2].votes = 0;
  
  
      int i = 1;
      int voters;
      char vote_name[7];
      printf(&quot;How many voters are here: &quot;);
      scanf(&quot;%i&quot;, &amp;voters);
      fgetc(stdin);
      for (voters; voters &gt; 0; voters--)
      {
          printf(&quot;Vote %i: &quot;, i++);
          fgets(vote_name, sizeof vote_name, stdin);
          check_vote(vote_name);
      }
      printf(&quot;%i&quot;, candidates[2].votes);
      return 0;
  }
  
  bool check_vote(char vote_name [])
  {
      for (int i = 0; i &lt; candidate_count; i++)
      {
          if (strcmp(candidates[i].name, vote_name) == 0)
          {
              candidates[i].votes++;
              return true;
          }
      }
      return false;
  }
  </code></pre>