title: Weird characters while getting str from a file in C
body: <p>I tried to get the file's content and put it into a string. When I run my program and I print the string I get the file's content with some weird characters afterward.</p>
  
  <p>My code:</p>
  
  <pre><code>int size = 0;
  char ch = 0;
  char* content = 0;
  FILE* fs = fopen(file, "r");
  //getting file's content and put it into a string
  while (ch != EOF)
  {
      ch = (char)fgetc(fs);
      size++;
      content = myRealloc(content, size);
      content[size - 1] = ch;
  } 
  printf("%s", content);
  </code></pre>
  
  <p>myRealloc:</p>
  
  <pre><code>char* myRealloc(char* array, int size)
  {
      char* temp = 0;
      temp = realloc(array, size * sizeof(char));
      return temp;
  }
  </code></pre>
  
  <p>The file's content:</p>
  
  <pre><code>1,2,3,4
  5,6,7,8
  a,b,c,d
  e,f,g,h
  </code></pre>
  
  <p>When I print:</p>
  
  <pre><code>1,2,3,4
  5,6,7,8
  a,b,c,d
  e,f,g,h ²²²²ר─
  </code></pre>