Du musst dir den Open mit den Parametern aus dem C-Handbuch mal genauer ansehen.
Mit "w" wird geöffnet und zurückgesetzt, Länge also wieder auf 0.
Siehe hier:
Mode Description
r
Open a text file for reading. The file must exist.
w
Create a text file for writing. If the given file exists, its contents are
destroyed unless it is a logical file.
a
Open a text file in append mode for writing at the end of the file. The
fopen()
function creates the file if it does not exist and is not a logical file.
r+
Open a text file for both reading and writing. The file must exist.
w+
Create a text file for both reading and writing. If the given file exists, its
contents are cleared unless it is a logical file.
a+
Open a text file in append mode for reading or updating at the end of the
file. The fopen() function creates the file if it does not exist.
rb
Open a binary file for reading. The file must exist.
wb
Create an empty binary file for writing. If the file exists, its contents are
cleared unless it is a logical file.
ab
Open a binary file in append mode for writing at the end of the file. The
fopen function creates the file if it does not exist.
r+b
or rb+
Open a binary file for both reading and writing. The file must exist.
w+b
or wb+
Create an empty binary file for both reading and writing. If the file exists,
its contents will be cleared unless it is a logical file.
a+b
or ab+
Open a binary file in append mode for writing at the end of the file. The
fopen()
function creates the file if it does not exist.
Ich denke du musst "a" verwenden, was allerdings nicht funktioniert, wenn die Datei neu ist.
Wenn alse der Open(..., "a, ...") fehlschlägt, dann mit Open(..., "w, ...") wiederholen.
Bookmarks