Help to get a string..
#1

I need to get something from the middle of a string, this is what I have:

pawn Код:
stock CorrectFile(const filename[])
{
    new buffer[256], buffer2[256], buffer3[256], sline1, count, startcount;
    new File: handle = fopen(filename, io_read);
    new File: tmp = fopen("part.part", io_write);
    fclose(tmp);
    tmp = fopen("part.part", io_append);
    while(fread(handle, buffer))
    {
        sline1 = strfind(buffer, '"');
        if(sline != -1)
        {
            strmid(buffer2, buffer, 0, sline1);
            format(buffer3, 256, "%s\r\n", buffer2);
            fwrite(handle, buffer3);
        }
    }
    fclose(handle);
    fclose(tmp);
    tmp = fopen("part.part", io_read);
    handle = fopen(filename, io_write);
    fclose(handle);
    handle = fopen(filename, io_append);
    while(fread(tmp, buffer))
    {
        fwrite(handle, buffer);
    }
    fclose(handle);
    fclose(tmp);
    fremove("part.part");
    return 1;
}
But the problem comes when I have more than a " in a single line, for example:

Код:
asdasda " adkaksd asD:D " akjsdkajd "
That will just write into the file:

Код:
asdasda
How can I correct this?

Thanks
Reply


Messages In This Thread
Help to get a string.. - by The_Moddler - 24.11.2010, 21:17
Re: Help to get a string.. - by Jefff - 25.11.2010, 00:28
Re: Help to get a string.. - by The_Moddler - 25.11.2010, 08:22
Re: Help to get a string.. - by Jefff - 25.11.2010, 14:08

Forum Jump:


Users browsing this thread: 1 Guest(s)