fwrite problem
#1

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?
Reply
#2

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!
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)