If I have a file containing some text data separated by some markers i.e '#####'
how would I go about deleting some part lets say the third in order.
If my file is like this
I was thinking about reading lines using fgets(line, MAX, fd) along with a counter so I can go to the separator before the thrid paragraph and the one after it. (The marked ones with *)#####
first paragraph
first line
#####
second paragraph
second line
*#####
third paragraph
third line
*#####
fourth paragraph
fourth line
#####
So I can get the positions in the file using ftell-strlen(line) when I am in the third and fourth occurrence of #####. Or I can use fseek when I am at the line I want and I just offset the negative length of len.
My question is how can I delete the text in between the marks so I could get something like this.
I think I should open the file in r+ mode so I can update it but I don't know what else. Can I use write and write some special character?#####
first paragraph
first line
#####
second paragraph
second line
#####
fourth paragraph
fourth line
#####