replace a line of a file

1 次查看(过去 30 天)
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

采纳的回答

per isakson
per isakson 2012-6-5
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

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by