replace a line of a file

1 Ansicht (letzte 30 Tage)
oblivious
oblivious am 5 Jun. 2012
Hello,
we know that we can read the lines of a file by using fgetl or fgets. But i need a function that will replace the lines of a file by a string, just the opposite thing of fgetl. is there such a function? doing this work manually is tedious, so i need such a function. please help
-OBLI

Akzeptierte Antwort

per isakson
per isakson am 5 Jun. 2012
It might be possible to do it inplace with memmapfile. If the lines are the same length, etc. I would not try. Try
loop over all lines
fgetl
if
fprintf
else
fprintf
end
end
to a new file

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by