I am trying to create a large file (5-50 MB) and I am looking for a quick way to do it. I know I can use calloc to allocate large areas in memory, but I'm not sure how to associate that with a file. I think fseek should also do it, but I also want to fill the memory with 0's.
I am making a bastardized file system which will exist as a large file and here is what I am currently doing.
fseek or lseek plus write should do the work. That means after call fseek/lseek to set the file size, you must call write to wirte at least 1 byte at the seeked location, then all file's bytes are 0 except what you write earlier.