open(), lseek() to the end of file, getting the size of file using tell(), and then allocating memory accordingly would work well as suggested above.
Unless there is specific reason to do it, fopen(), fseek(), ftell() is a better idea (portable staying within the C standard library).
This certainly assumes that the file you are opening is small. If you are working with large files, allocating memory for the whole of file may not be a good idea at all.
You may like to consider using memory mapped files for large files. POSIX systems provide mmap() and munmap() functions for mapping files or devices in memory. See mmap man page for more description. Memory mapped files work similar to C arrays though the responsibility of getting actual file data is left to the OS which fetches appropriate pages from disk as and when required while working on the file.
Memory mapped files approach has limitations if the file size is bigger than 32-bit address space. Then you can map only part of a file at a time (on 32-bit machines).