-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteFile.c
More file actions
37 lines (31 loc) · 890 Bytes
/
Copy pathdeleteFile.c
File metadata and controls
37 lines (31 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
// Function to delete the file with the given filename
void deleteFile() {
char filename[100];
// Ask the user to input the name of the file to delete
printf("Enter the name of the file to delete: ");
scanf("%s", filename); // Read the filename
// Delete the file
if (remove(filename) == 0) {
printf("File '%s' deleted successfully.\n", filename);
} else {
printf("Error deleting the file '%s'. File may not exist.\n", filename);
}
}
int main() {
int choice;
while (1) {
deleteFile();
printf("\nActions:\n");
printf("1) Continue 2) Exit\n");
printf("Choice: ");
scanf("%d", &choice);
if (choice == 1) {
continue;
} else {
break;
}
}
return 0;
}