offset=ftell(ptr)-sizeof(student1); fseek(ptr,offset,SEEK_SET); fwrite(&student1,sizeof(student1),1,ptr);
This C code means moving the pointer from the current ftell(ptr) position to start the just-read structure block. I'm right?
If I am right, can I use SEEK_CUR instead of SEEK_SET to return to the beginning of the structure block in the file?
Please show me how to use SEEK_CUR and go to the beginning of the structure block.
I am new to programming. So please kindly help me.
Edit: Thanks for the answers. What I'm trying to do is search for a keyword (studentβs roll number) and update information about this student (name, address, ..). Updated data replaces previous data successfully. Let me ask one more question. Is there a way to insert new data over previous data instead of replacing it with old data?
source share