I want to read a text file line by line, perform some checks, and if the line is not required, delee it. I have done the code for reading line, but I don't know how to delete that line if it is not required by me. Please help me find the simplest method for deleting the line. Here is my code snippet for reading the line:
char string[16];
int number;
DWORD dwWritten;
FILE *fp;
HANDLE hFile;
hFile=CreateFile("File.txt",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
WriteFile(hFile,"Line 1\n\nLine 2\n\n",strlen("Line 1\n\nLine 2\n\n"),&dwWritten,0); fp = fopen("File.txt", "r");
while (fscanf(fp, " %s %d", string, &number) > 0) {
if(number == 2)
{
}
}