getting the size of the buffer

What are some alternatives to the following:

1
2
3
4
5
6
7
8
// obtain file size:
  fseek (pFile , 0 , SEEK_END);
  lSize = ftell (pFile);
  rewind (pFile);

  // allocate memory to contain the whole file:
  buffer = (char*) malloc (sizeof(char)*lSize);
  if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}


I'd like a way to cut out fseek.
you want the size of a file ?
Topic archived. No new replies allowed.