General information
Category:
Coding, syntax & commands
>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.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only