title: Reading a file character by character in C
body: <p>I'm writing a BF interpreter in C and I've run into a problem reading files. I used to use <code>scanf</code> in order to read the first string, but then you couldn't have spaces or comments in your BF code.</p>
  
  <p>Right now here is what I have.</p>
  
  <pre><code>char *readFile(char *fileName)
  {
    FILE *file;
    char *code = malloc(1000 * sizeof(char));
    file = fopen(fileName, "r");
    do 
    {
      *code++ = (char)fgetc(file);
  
    } while(*code != EOF);
    return code;
  }
  </code></pre>
  
  <p>I know the problem arises in how I'm assigning the next char in the file to the code pointer but I'm just not sure what that is.<br>
  My pointer knowledge is lacking  which is the point of this exercise.
  The interpreter works fine, all using pointers, I'm just having a problem reading files in to it.</p>
  
  <p>(I'm going to implement only reading <code>+-&gt;&lt;[].,</code> into the file later, although if anyone has a good way to do it, it would be great if you'd let me know!)</p>