fwrite problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: fwrite problem (
/showthread.php?tid=407880)
fwrite problem -
2KY - 15.01.2013
pawn Код:
stock PrintToSourceLog ( text [ ] )
{
new
File: SourceLog = fopen ( "Source/Logs.src", io_write ),
String [ 128 ];
format( String, 128, "%s\r\n", text );
fwrite ( SourceLog, String );
fclose ( SourceLog );
return true;
}
pawn Код:
PrintToSourceLog ( "hello" );
PrintToSourceLog ( "Hi" );
Would only yield the latter of the two prints, what am I doing wrong? Oh, and is there a way I could do this with Y_INI rather than file functions?
Re: fwrite problem -
Babul - 16.01.2013
a less "dangerous" way to open a file for saving, try io_append instead of io_write ,i never encountered a "file not opened for saving = crash" error anymore. opening with "append" creates a file if not yet existing btw - iam pretty sure this is your solution!
Re: fwrite problem -
LarzI - 16.01.2013
Quote:
Originally Posted by Babul
a less "dangerous" way to open a file for saving, try io_append instead of io_write ,i never encountered a "file not opened for saving = crash" error anymore. opening with "append" creates a file if not yet existing btw - iam pretty sure this is your solution!
|
This is true.
Quote:
Originally Posted by SA-MP Wiki: File Functions
io_write Writes in a file, clears all earlier written text
|
As you can see, io_write will clear all existing data in the file and write new data.