#include <stdio.h>
int main ()
{
char filename[] = "file.txt";
FILE * fp ;
fp = fopen(filename, "r");
if(fp == NULL)
{
printf("This file NOT exists");
return 0;
}
else
{
fp = fopen(filename, "r");
if(fp == NULL)
{
printf("This file is exists and can not reading \n");
}
else
{
printf("This file is exists and can reading ");
}
}
int ret;
char oldname[] = "file.txt";
char newname[] = "newfile.txt";
ret = rename(oldname, newname);
if(ret == 0)
{
printf("File renamed successfully\n");
}
else
{
printf("Error: unable to rename the file");
}
fclose(fp);
ret = 0;
ret = remove(newname);
if(ret == 0)
{
printf("File deleted successfully");
}
else
{
printf("Error: unable to delete the file");
}
return(0);
}
C rename remove fopen
原创
©著作权归作者所有:来自51CTO博客作者mb61ced0f6e4a25的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:vim 基础篇
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java map循环中remove
java map循环中remove
迭代 Java 迭代器