Information générale
Catégorie:
Codage, syntaxe et commandes
>Hello,
>I want to create a error log file, but I don't know how to write to a file without loosing the existing text.
>Is there a easy way to write "additive" to file?
>Thanks for your help!
If your using low-level functions try something along the lines of :
fhandle = fopen("FILE",2) && try to open file
if (fhandle == -1) && if failed
fhandle = fcreate("FILE") && create file
else
fseek(fhandle,0,2) && otherwise seek to end of file
endif
&& now can append write to file
BTW - beware of letting the file grow too big. I normally put a check on the file size & create an archive copy once it reaches a certain size, after getting massive log files due to a network failure, appending to the file once a second for an entire weekend.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement