Writting to a .tx file
이전 댓글 표시
I am creating a high score table for a game. I created a .txt file that has a name in the first column and a two digit score in the second column.
I am trying to make it so a user can input their name and their score onto the file.
So far I have... fid = fopen('HighScoreTable.txt', 'w');
data = textscan(fid, '%s %d');
close = fclose(fid);
names = data{1}
scores = data{2}
But it is giving me this error message ..
Error using textscan Unable to read any data from the file, textscan may not have read access.
Error in Table (line 5) data = textscan(fid, '%s %d');
답변 (1개)
per isakson
2013년 4월 22일
Writing or reading?
Try
fid = fopen('HighScoreTable.txt', 'r' );
with an "r" for reading. textscan does only reading.
카테고리
도움말 센터 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!