Editing a specific liine of text file - C++

Is there any way to erase all the contents of a specific line of a text file and then write something on it?
e.g.
test.txt.old:

qwert
asdfg
zxcbv=0

test.txt.new

qwerty
asdfg
hello=0

is this possible with C++ ?:confused:

You can overwrite data if the length doesn't change. open the file with fopen(), seek to the correct spot with fseek(), then write the data with fwrite().

If the length changes, everything after the change will have to be written back in a new position because files have no "insert" operation.