title: Removing newline from fgets
body: <p>I am sorry if this question is obvious, or if I am making a simple logic mistake. I have searched for various ways of getting rid of the newline that comes from using fgets, but I continue running into problems while building. I think I am not understanding something properly and applying my "solution" incorrectly. I would like to be transparent and say that this is an assignment for school. Everything runs well except my output, which has unnecessary new lines.</p>
  
  <p>The sole purpose of this function is to read names into an array of structs.</p>
  
  <pre><code>void initialize(FILE * ifp, Candidate * electionCandidates, int count)
  {
  
  for (int i = 0; i &lt; count; i++)
  {
  
      fgets (electionCandidates[i].name , 20 , ifp);
  
      if (electionCandidates[i].name[strlen(electionCandidates[i].name) - 1] == '\n')
      {
          electionCandidates[i].name[strlen(electionCandidates[i].name) - 1] = '\0';
      }   
  } 
  }
  </code></pre>
  
  <p>The following is displayed when I attempt to run: "Implicitly declaring library function "strlen" with type unsigned long (constant char*)"</p>