modify txt file in C
i met some problem in this.
i used fseek to locate position prepared to be written.
while time will be users input.
the content of the txt file to be modified
aabb, ccddeeff, 30gghhiijjkk
obvious the string 30(at byte position 16)
is going to be changed.
but if users input were 3000
then gg(position 18) will be overwrote.
i will get the result
aabb, ccddeeff, 3000hhiijjkk
but all i need is
aabb, ccddeeff, 3000gghhiijjkk
or EVEN users input were 300000
i still need the result to be
aabb, ccddeeff, 300000gghhiijjkk
how to do it?
You read the file line by line
You change each line to suit
You write the line to a new temporary file.
When you're done, close both files, delete the original and rename the temporary.