Answer the question
In order to leave comments, you need to log in
Write a C program that deletes a file that starts with 'a' in a directory?
How to write a C program that deletes a file that starts with 'a' in a directory?
Answer the question
In order to leave comments, you need to log in
We need to go through the list of names in the directory, then select the file names from them, and then apply remove() to those names that have the first character 'a'.
You can view the list of names only through a system call (opendir() + readdir() + closedir()). You can also request information about the name only through the system call (stat()). You can only check the name for the presence of a character and remove the file through the standard library (f[0] == 'a' + remove()).
In theory, file names still need to be read in Unicode.
For a beginner, the task is not easy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question