This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

fopen - raw data as stream data in C

I need to create a FILE struct from data stored into an array. In my code I have the fopen function, which returns a FILE. The idea is to read all data stored in array, convert to FILE struct and finally return the FILE.

I.e:

FILE validFile (char *fileName){
     char *data;
     FILE *fp;

     data = malloc(sizeof(char*));

     populateData(data);

     fp = fopen(data, "r");

     return fp;
}

Is that possible?

Similar function exists in GLIB C library; fmemopen.

Thanks and best regards,

Cristian.