I am currently using fseek()
in program. I have also maintained an array of bytes which keeps the track of bytes of each line that is printed inside the file.I am also using a segment tree, so that the access to a particular position is faster. Also, I am not allowed to use anything else...(like structs)
Is there a way to do so?
Maybe there are better options than this but you can do something like this
store the position pointer from where you wish to delete. // variable1 store in another variable the seek position from where the delete operation must end.
now from the position where the delte must end till end of file, read the values into a buffer. Now again seek back to variable1 and start appending from that position the contents stored in buffer. Ultimately add EOF once the append operation is complete.
Easier method but even more memory/time intensive: read the whole file into a buffer. now replace the contents into buffer. again open the same file but in "write" mode and empty the buffer into file. This will over write everything without creating a new file.
Hope someone puts forth a better solution :)