Hello, I am from Turkey and I'm new here I need help with the code below:
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: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; }
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?c:\\3-1.exe
c:\\sile.exe
c:\\a.txt
c:\\b.txt
c:\\c.txt
c:\\e.txt
c:\\d.txt