S
S
Stas Karter2015-10-16 19:51:58
C++ / C#
Stas Karter, 2015-10-16 19:51:58

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

2 answer(s)
A
abcd0x00, 2015-10-17
@Error1349

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.

V
Vladimir Martyanov, 2015-10-16
@vilgeforce

Take and write.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question