title: char * printing out strange characters
body: <p>I have a function that takes a <code>char ** const</code>as a parameter, and a file pointer. What I'm trying to do is in the file, if I SEE A LINE with white space, I’ll remove the "\r\n" characters from the line and store it in my variable. However, upon printing the variable out, I seem to be getting strange output.</p>
  
  <p>The Textfile:</p>
  
  <pre><code>TestFILE
  NUMBER
  1
   whiteSpaceHere
   MoreWhiteSpace
  </code></pre>
  
  <p>..
  As you can see, I have two lines that contain blatant whitespace.
  And I have the functions (The reason I'm using const, and double pointers is because my project requires them (I'm not allowed to change function definitions) </p>
  
  <pre><code>int main(void) {
      char * temp;
  
      FILE * file = fopen("test.txt","r");
      if(file == NULL) { return 0; }
  
      testFunc(file, &amp;temp);
  
      printOut(temp);
  
      return 0;
  }
  
  void testFunc(FILE * file, char ** const buffer) {
      char buf[256];
  
      *buffer = malloc(sizeof(buf));
  
      while(fgets(buf,sizeof(buf,file) != NULL ) {
          if(isspace(buf[0]) {
              strtok(buf,"\r");
              strtok(buf,"\n");
  
              *buffer = buf;
          }
  
      }
  }
  
  //function to later free all alocated memory...
  //void freeVars
  
  void printOut(char * const print) {
      printf("The Value is %s\n,"print);
  
  }
  </code></pre>
  
  <p>I'm trying to print it out here, to ensure the parsing works. I'm aware that it's a const variable, but I can't change that (This is just a snipit of my code) to test the parsing functionality. 
  I tried to print out the buffer prior to the function call but that yielded the same result (Gibberish output). </p>
  
  <p>I believe the issue might be with the NULL terminator, but I'm not sure how to go about approaching that. I'm told that the buffer passed, has to then contain a line (which had whitespace), and then has it's <code>"\r\n"</code> characters removed. I believe I've done that with strtok, however, I'm not sure why I'm getting strange output .</p>