<分区>
我很难在我的 C 代码中进行系统调用以取消链接文件工作。我想在复制代码后从文件系统中删除文件。我收到一条错误消息:
declared here extern int unlink (const char *__name) __THROW __nonnull ((1));
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
int main(int argc, char * args [])
{
int infile, outfile;
int numofbytesread;
char buffer[20];
infile = open(args[1], O_RDONLY, 0700);
if (infile == ENOENT)
{
printf("Could not find file");
return 1;
}
outfile == open(args[2], O_WRONLY | O_CREAT, 0700);
while ((numofbytesread = read(infile, buffer, 20))){
write(outfile, buffer, numofbytesread);
}
close(infile);
close(outfile);
unlink();
return 0;
}