How can I make a text file that I can edit after each time I run a program?
Show older comments
I want to print to a text file the name, score, and board size of the user once a user has completed a simple game I designed. I can do that task just fine, but I also want to display all of the previous users and their scores and board sizes as well and just add the most recent user to the list. If anyone can help that would be great.
this is what I have so far (there are values for Name, Score, and Size)
if true
fid=fopen('results.txt','w');
fprintf(fid, ['Name' '\t\t' 'Score' '\t' 'Board Size' '\n']);
fprintf(fid, '\n%s\t\t%d\t\t%d\n', Name, Score, Size');
fclose(fid);
end
Accepted Answer
More Answers (1)
Walter Roberson
on 29 Nov 2015
fid = fopen('TheScoreFile.txt', 'at');
fprintf(fid, 'this line will be appended to the file\n');
fclose(fid)
Categories
Find more on Standard File Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!