Deleting multiple files using C
Hello, I am from Turkey and I'm new here :) I need help with the code below:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *input;
char operation[1026];
input = fopen("av.txt", "r");
while(!feof(input)) {
fgets(operation, 1024, input);
puts(operation); // Checking if fgets is working properly
remove(operation);
}
fclose(input);
return 0;
}
What I am triyng to do is reading file paths from the input file av.txt and deleting those files using the remove() funtion. But what I dont understand is that the program only deletes the last file in the av.txt. For example this is the av.txt:
Quote:
c:\\3-1.exe
c:\\sile.exe
c:\\a.txt
c:\\b.txt
c:\\c.txt
c:\\e.txt
c:\\d.txt
The program only deletes c:\\d.txt. I mean it only deletes the last line. But when I check if fgets is working normal by using puts evertything seems fine. The puts function lists av.txt with no error. What is the problem? How will I delete all these files?