I have multiple tiff images stored inside a zip file and would like to read their pixel values in c. I am very new to c so please forgive the dodgy code. I have got to the point where I have a char * with the contents of the tiff file but can't seem to work out how to now process that with libtiff (or something similar). libtiff seems to require that I pass TIFFOpen a filename to open. I could write the tiff to a temporary file but it feels like there must be a more efficient way. 
So far I have:
#include <stdlib.h>
#include <stdio.h>
#include <zip.h>
#include <string.h>
int main()
{
    //Open the ZIP archive
    int err = 0;
    struct zip *z = zip_open("test.zip", 0, &err);
    // Determine how many files are inside and iterate through them
    int num_files = zip_get_num_entries(z, 0);
    printf("%u\n", num_files);
    int i;
    for (i=0; i < num_files; i++)
    {
        const char * filename;
        filename = zip_get_name(z, i, 0);
        // If the file name ends in .tif
        if (strlen(filename) > 4 && !strcmp(filename + strlen(filename) - 4, ".tif"))
        {
            printf("%s\n", filename);
            // Get information about file
            struct zip_stat st;
            zip_stat_init(&st);
            zip_stat(z, name, 0, &st);
            printf("%lld\n", st.size);
            // Allocate memory for decompressed contents
            char *contents;
            contents = (char *)malloc(st.size);
            // Read the file
            struct zip_file *f = zip_fopen(z, filename, 0);
            zip_fread(f, contents, st.size);
            zip_fclose(f);
            // Do something with the contents
            // Free memory
            free(contents);
        }
    }
    //And close the archive
    zip_close(z);
}
EDIT: My question is similar to this one but the accepted answer there relates to c++ and I'm not sure how to translate it to straight c.