Delete 1 line in file
#6

I have this

Code:
stock fdeleteline(filename[], dest[], remove[])
{
  new string[255], File:handle, File:ftmp;

  handle = fopen(filename, io_read);
  ftmp = fopen(dest, io_write);
  while(fread(handle, string)){
    for(new i = 0, j = strlen(string); i < j; i++) if(string[i] == '\n' || string[i] == '\r') string[i] = '\0';
 		if(strcmp(string, remove, false) != 0) fwrite(ftmp, string);
  }
  fclose(handle);
  fclose(ftmp);
  handle = fopen(filename, io_write);
  ftmp = fopen(dest, io_read);
  while(fread(ftmp, string)){
  for(new i = 0, j = strlen(string); i < j; i++) if(string[i] == '\n' || string[i] == '\r') string[i] = '\0';
	fwrite(handle, string);
	}
  fclose(handle);
  fclose(ftmp);
  fremove(dest);
}
but this write

Code:
sdf sffsfa dgsd dhfh dghfh
without spaces and I want that

Code:
sdf
sffsfa
dgsd
dhgfh
Reply


Messages In This Thread
Delete 1 line in file - by Jefff - 07.04.2009, 20:34
Re: Delete 1 line in file - by Nubotron - 07.04.2009, 20:55
Re: Delete 1 line in file - by Jefff - 07.04.2009, 22:04
Re: Delete 1 line in file - by Nubotron - 07.04.2009, 22:58
Re: Delete 1 line in file - by ICECOLDKILLAK8 - 07.04.2009, 23:07
Re: Delete 1 line in file - by Jefff - 07.04.2009, 23:54
Re: Delete 1 line in file - by Nubotron - 08.04.2009, 00:34

Forum Jump:


Users browsing this thread: 1 Guest(s)