Hello everyone,
Just want to check with all of you. Let say if I used ftell and fseek to position the pointer, can I use it to delete all the text that is beyond the position? Any suggestion?
Hello everyone,
Just want to check with all of you. Let say if I used ftell and fseek to position the pointer, can I use it to delete all the text that is beyond the position? Any suggestion?
No you can't.
Anything more complicated than just appending to the end of the file requires you to recreate the file by reading the old file and applying your "edits" as you go (whether it be insert, modify or delete).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.