struct stat fileStat; size_t fileSize; fd = open(filename, O_RDONLY); fstat(fd, &fileStat); fileSize = fileStat.st_size;