Thank you for help. I could read both using fread and fscanf in different copies of
the same proogram by allocating memory(malloc) char * fields of the struct or else by scanf/printf on each field separately .

Thank you for help. I could read both using fread and fscanf in different copies of
the same proogram by allocating memory(malloc) char * fields of the struct or else by scanf/printf on each field separately .

Though fread reads the written record, it only repeatedly shows the last record read , as many times as many records were written into the file.

I'm able to get all records using fscanf, but i also want to know how it could be done using fread and void pointers. So, Please tell.

Well, you will need to read it to somewhere, so you will need an array which you may have to reallocate if you run out of space, an array of pointers which you must allocate each element for and reallocate if you run out of space or some other type of container (preferably one that will do the allocation for you ;)).

So, have you used malloc() and free() before? What about them do you not understand?

Well, you will need to read it to somewhere, so you will need an array which you may have to reallocate if you run out of space, an array of pointers which you must allocate each element for and reallocate if you run out of space or some other type of container (preferably one that will do the allocation for you ;)).

So, have you used malloc() and free() before? What about them do you not understand?

Adrian

Yes I do understand the functions performed by malloc and free.Though I
use malloc(and calloc) often , I haven't worked much with free(may be because I wrote small programs ). For the allocations done in this program, i'm sending that section too.

Don't write pointers to a file. It doesn't make sense. Tell me, what would happen if you read in a bunch of pointers using a different app? The pointers will not be valid in that app (if it is valid here it is barely valid).

Write the contents, not the pointer.

Anciant proverb: It is the fool who looks at the finger that is pointing at the moon. (or something like that ;)).