title: read a specific number of characters in the text file using fread and fseek
body: <p>Let's say I have a text file like this</p>
  
  <blockquote>
    <p>This is a text file which contains some numbers.</p>
  </blockquote>
  
  <p>So I want to use fseek and fread to read some parts of the text file.
  For example, from position 0 to 13, I'll get "This is a text". 
  Then from position 14 to 24, I'll get " file which", then from position 25 to the end of file, I'll get " contains some numbers."</p>
  
  <p>I've tried to use fseek and fread but I've got some additional weird characters like "This is a text?"</p>
  
  <p>My attempt to use fseek and fread:</p>
  
  <pre><code>src = fopen(textfile, "r");
  int chunksize = data[i].end - data[i].start;
  char *buffer = malloc(sizeof(chunksize));
  
  seek(src, data[i].start, SEEK_SET);
  fread(buffer, 1, chunksize, src);
  fseek(src, 0, SEEK_SET); // seek back to beginning of file      
  </code></pre>
  
  <p>where <code>data[i].start</code> is the start position to read to part and <code>data[i].end</code> is the end position to stop. For example, from 14 to 24, I'll get " file which". start is 14 and end is 25.</p>