[Question] fopen mode - io_readwrite
#1

Is the mode io_readwrite used for reading and writing? so you could read from the file and write without reopening it?
Reply
#2

Quote:
Originally Posted by SA-MP Wiki
io_readwrite Reads the file or creates it
Taken from the SA-MP wikipedia.

This simply reads the file, and if it is not created yet, it creates it.

So no, you will need to read and write it. You could always do something like this:

pawn Код:
new File:example = fopen("file.txt", io_readwrite);
if(example) //If it exists, it writes.
{
    fwrite(example, "Whatever you want to write");
    fclose(example);
}
else
{
    fread(example, string[], sizeof(string));
    fclose(example);
}
Not sure if something like that would work. I do not use this kind of saving/loading, considering I use y_ini or mysql.

EDIT: Just realized what I might have done wrong. I honestly have no idea what if(example) means, I figured it means if it exists. Then again, this might go wrong, considering if the file is being written (io_readwrite) then it would always do that and not continue to the else section.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)