fwrite doesn't work
#1

Any clues ?
print(temp) shows the right string, fwrite returns something (so it actually writes something) but the file is empty

PHP код:
main()
{
    new 
File:handle fopen("playerclass.txt"io_read);
    new 
buffer[128], temp[80], File:cpos fopen("createpos.txt"io_append), rest[48], Float:xFloat:yFloat:zFloat:a;
    if(
handle)
    {
        while(
fread(handlebuffer))
        {
            
sscanf(buffer"'AddPlayerClass(240,'p<,>ffffs[48]"xyzarest);
            
format(tempsizeof(temp), "CreatePos(%.4f, %.4f, %.4f, %.4f);\n"xyza);
            
fwrite(cpostemp);
        }
    }

Reply
#2

Because you can't open a file in "read mode" and try to write on it. Open in "io_write" mode.

https://sampwiki.blast.hk/wiki/Fopen
Reply
#3

Quote:
Originally Posted by EnzoMetlc
Посмотреть сообщение
Because you can't open a file in "read mode" and try to write on it. Open in "io_write" mode.

https://sampwiki.blast.hk/wiki/Fopen
Well you might be confusing, because 'cpos' is opened with io_append ...
Reply
#4

My bad, sorry.
Anyway, to skip a line, use "\r\n".

And you should close file to "save changes".
https://sampwiki.blast.hk/wiki/Fclose
Reply
#5

Quote:
Originally Posted by EnzoMetlc
Посмотреть сообщение
My bad, sorry.
Anyway, to skip a line, use "\r\n".

And you should close file to "save changes".
https://sampwiki.blast.hk/wiki/Fclose
Thank you
Reply
#6

use fclose(handle); in end
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)