Saturday, 31 May 2014

Implement in C the Unix command mv using system calls


Implement in C the Unix command mv using system calls

#include<fcntl.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/stat.h>
int main(int argc, char **argv)
{
   int fd1,fd2;
   int n,count=0;
   fd1=open(argv[1],O_RDONLY);
fd2=creat(argv[2],S_IWUSR);
rename(fd1,fd2);
unlink(argv[1]);
return (0);
}
  
  

No comments: