I am opening a Courses.dat file and need to read specific bytes on each line. For some reason, after opening the file, I get a segmentation fault on ANYTHING I do to it. I have tried opening with "r" and "rb", but nothing works. This might not be enough code to determine the error but I am just wondering what the possible cause could be for a seg fault immediately after opening a file.

I have checked that the file exists, the file name is correct, I can open and close the file successfully, but as soon as I do anything with it, it fails.

Code:
    if((datP = fopen(fname, "r")) == NULL) {              /*open .dat file*/
      fprintf(stderr,"Error opening .dat file.\n");   exit(1);
    }
  fseek(datP,0L,SEEK_END);
  fileLen = ftell(datP);
  fseek(datP,0L,SEEK_SET);
  printf("fileLen: %d",fileLen);