How to write the first line in a text file when opened file as 'a+'
古いコメントを表示
I'am having issues rewriting the first line of a text file when I open the file as 'a+'. Example:
file = fopen('example.txt','a+'); frewind(file); fprintf(file,'%f %u %u',version, numlines, newChecksum); fclose(file);
The objective of the code is to add update the information from the first line of the file. The problem is that when I do the fprintf() it writes the info. at the end of the file not at the beginning where the file pointer is currently located after the frewind(). I have also tried the fseek. Both frewind and fseek work because if I use the command fgets() to get the first line it dose get the info. located at the beginning to the file.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Low-Level File I/O についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!