Load a file from another file
#5

I think this may be a SA:MP bug, although I'm not sure. I don't think it used to happen? Anyhow, in order to fix it you have to manually loop through the array and find the \r\n, once you find them then set them to 0 (string terminator)

e.g.

You could do something like this (untested) function to terminate the string at a new line, which should be fine for fread as it works line by line (i.e. \r\n)..

pawn Код:
TerminateNL(string[], start = 0, len = sizeof string)
{
    // It's assumed a string so we'll make sure it has a null terminator at the end.
    string[len-1] = 0;

    while(string[++start]) {
        if (string[start] == '\r' || string[start] == '\n')
            string[start] = 0; // You could put a "break;" statement here if you wish to not terminate all NL characters for efficiency. The string should "end" when it reaches the first string terminator.
    }
}
Reply


Messages In This Thread
Load a file from another file - by ppanlie - 30.08.2010, 04:42
Re: Load a file from another file - by Backwardsman97 - 30.08.2010, 04:56
Re: Load a file from another file - by ppanlie - 30.08.2010, 05:08
Re: Load a file from another file - by Voldemort - 30.08.2010, 07:08
Re: Load a file from another file - by Simon - 30.08.2010, 07:24

Forum Jump:


Users browsing this thread: 1 Guest(s)