Appending to text files

조회 수: 18 (최근 30일)
alexander
alexander 2012년 3월 12일
Hello, this is a fairly simple problem and i have come up with a simple enough solution. I need to append alot of text files to one master file.
i did this
clear all
clc
fid=fopen('t1.txt','a+');
fod=fopen('t2.txt');
while ~feof(fod)
fprintf(fid,'\n%s',(fgetl(fod)));
end
fclose('all');
Pretty simple right? It works well too. It appends everything in t2.txt to t1.txt. I have a suspision their is a better way to do this task though. The end of file identifier is what annoys me. Has anyone got a better way?

답변 (1개)

Walter Roberson
Walter Roberson 2012년 3월 12일
short summary: feof() never predicts end of file.

카테고리

Help CenterFile Exchange에서 Other Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by