K
Kuhl
Hi, I am writing Linux C program. How to remove a file with C command?
My book only shows how to remove a hard link or a directory.
Remove a hard link:
#include <unistd.h>
.... ...
int unlink(const char *pathname);
.... ...
if(unlink("test2.txt")==-1){
....
}
Remove a directory:
#include <unistd.h>
.... ...
int rmdir(const char *pathname);
....
My questions:
(1) It does not describe how to remove a regular file. How to do that?
(2) Both removing a hard link and removing a directory has the inputs
of (const char *pathname). Why it's const?
Thank you in advance.
My book only shows how to remove a hard link or a directory.
Remove a hard link:
#include <unistd.h>
.... ...
int unlink(const char *pathname);
.... ...
if(unlink("test2.txt")==-1){
....
}
Remove a directory:
#include <unistd.h>
.... ...
int rmdir(const char *pathname);
....
My questions:
(1) It does not describe how to remove a regular file. How to do that?
(2) Both removing a hard link and removing a directory has the inputs
of (const char *pathname). Why it's const?
Thank you in advance.