24.11.2010, 21:17
I need to get something from the middle of a string, this is what I have:
But the problem comes when I have more than a " in a single line, for example:
That will just write into the file:
How can I correct this?
Thanks
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;
}
Код:
asdasda " adkaksd asD:D " akjsdkajd "
Код:
asdasda
Thanks