Borrar filtros
Borrar filtros

replace a line of a file

3 visualizaciones (últimos 30 días)
oblivious
oblivious el 5 de Jun. de 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

Respuesta aceptada

per isakson
per isakson el 5 de Jun. de 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

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by