how do I go about overwriting a specific line on a text file in c?. I have values in multiple variables that need to be written onto the file.
This only works when the new line has the same size as the old one:
a+
fseek()
to the start of the fileftell()
to note the start of the linefseek()
again with the result from ftell()
and use fwrite()
to overwrite it.If the length of the line changes, you must copy the file.