title: function using fopen() keeps opening the same file, even if given different filenames as parameters
body: <p>I'm trying to open multiple files sequentially, using fopen(), just printing the contents and counting the chars. 
  In main() I call the function twice using different filenames but the function just prints the contents of the <strong>first</strong> file <strong>twice</strong>. Both files do exist, of course, and just calling this function once does print the correct contents; tested with both files. There just seems to be a problem when calling the function multiple times.</p>
  
  <p>Can somebody please give me a hint? What could be wrong?</p>
  
  <p>My function:</p>
  
  <pre><code>void open_and_read(char file_name[80]){     
      char c;
      int buf_length = 16384;
      char buf[buf_length];
      char* buf_pointer;
      int i = 0;
      FILE *file_pointer;
      file_pointer = fopen(file_name,"r");
      buf_pointer = buf;
      if(file_pointer==NULL){
          printf("Error: File %s not opened!", file_name);
      }
      else {
          while(c!=EOF &amp;&amp; i&lt;(buf_length-1)){
              c = fgetc(file_pointer);
              *buf_pointer = c;
              buf_pointer++;
              i++;
          } 
          buf_pointer--;
          *buf_pointer = 0;
          printf("The file %s contains the follwing: \n%s", file_name, buf);
          printf("char-count: %i\n", i);
      }
      if(fclose(file_pointer)!=0){
          printf("File was not closed!");
      }
      else {
          printf("File was successfully closed!"); 
      }
  }
  </code></pre>
  
  <p>main():</p>
  
  <pre><code>int main(){
      open_and_read("/home/x201/dev/IB/data/line1.dat");
      open_and_read("/home/x201/dev/IB/data/line2.dat");
  </code></pre>