Code:
typedef struct _S_
{
void *data;
struct _S_ *next;
}s
FILE *fp = NULL;
//Open the File
fp = fopen("MyFile.txt","r");
char *buffer;
long lSize;
size_t result;
if(fp)
{
fseek (fp , 0 , SEEK_END);
lSize = ftell (fp);
rewind (fp);
// allocate memory to contain the whole file:
buffer = (char*) malloc (sizeof(char)*lSize);
if (buffer == NULL)
{
puts ("Memory error",stderr);
exit (2);
}
// copy the file into the buffer:
result = fread (buffer,sizeof(char),lSize,fp);
if (result != lSize)
{
fputs ("Reading error",stderr);
exit (3);
}
//Here I want to store the buffer to the Structure ( void * data)
}
fclose(fp);
}
