linux remove和 rename函数使用

#include<stdio.h>
#include<stdlib.h>

int main()
{
   int ret = rename("./file_mmap","/root/file_mmap");  
   if(ret<0)
   {
     perror("rename error\n");
   }
   /***
   (1) 本路径重命名 
   (2) 移动文件    注意要使用绝对路径 不能使用相对路径
   **/
   remove("aabc.c");  // 删除文件     都是c库
   printf("ret is %d\n",ret);
   while(1);

 return 0;
}

猜你喜欢

转载自www.cnblogs.com/nowroot/p/12749279.html