title: Function to remove newline has no effect?
body: <p>I have written a function to wrap GNU getline() and remove the trailing newline, but for some reason it has no effect. Am I doing something wrong?</p>
  
  <pre><code>ssize_t readline(char **lineptr, FILE *stream)
  {
    size_t len = 0;  // Size of the buffer, ignored.
  
    ssize_t chars = getline(lineptr, &amp;len, stream);
  
    if((*lineptr)[chars] == '\n') {
      (*lineptr)[chars] = '\0';
      --chars;
    }
  
    return chars;
  }
  </code></pre>
  
  <p>It compiles and links without problems, but the newline is not replaced with a null-terminator. I've verified the if() statement is running. Thanks for any help!</p>