Search
 
SCRIPT & CODE EXAMPLE
 

C

c program to implement mv command

#include<sys/types.h>
#include<sys/stat.h>
#include<stdio.h>
#include<fcntl.h>
main( int argc,char *argv[] )
{
int i,fd1,fd2;
char *file1,*file2,buf[2];
file1=argv[1];
file2=argv[2];
printf("file1=%s file2=%s",file1,file2);
fd1=open(file1,O_RDONLY,0777);
fd2=creat(file2,0777);
while(i=read(fd1,buf,1)>0)
write(fd2,buf,1);
remove(file1);
close(fd1);
close(fd2);
}
Comment

c program to implement mv command

#include<sys/types.h>
#include<sys/stat.h>
#include<stdio.h>
#include<fcntl.h>
main( int argc,char *argv[] )
{
int i,fd1,fd2;
char *file1,*file2,buf[2];
file1=argv[1];
file2=argv[2];
printf("file1=%s file2=%s",file1,file2);
fd1=open(file1,O_RDONLY,0777);
fd2=creat(file2,0777);
while(i=read(fd1,buf,1)>0)
write(fd2,buf,1);
remove(file1);
close(fd1);
close(fd2);
}
Comment

PREVIOUS NEXT
Code Example
C :: how to transform a char to ascii code in c 
C :: C program to input the month number and output the month name using switch statement 
C :: how to select numeric columns in r 
C :: search sorted array c 
C :: lxc Failed to load config for 
C :: square in c 
C :: how to input till end of line in c 
C :: fread 
C :: C Program to Check Whether Character is Lowercase or Not using islower function 
C :: insert image material ui 
C :: get boolean from localstorage 
C :: c unused variable 
C :: C Input and Output Array Elements 
C :: objects in oops 
C :: linear and binary search 
C :: yt derived field 
C :: gcc compiler for windows 10 
C :: Here is a program in C that illustrates the use of fprintf() to write a text file: 
C :: How can you invoke the constructor from the parent class? *ruby 
C :: Talk about the difference between call by reference and call by value and in C language with example? 
C :: print integer to stdout using write or putchar? 
C :: extended euclidean algorithm to find x and y 
C :: curl ftp upload file to directory 
C :: turn on and turn off different device at the same time in rainmaker 
C :: C (K&R) 
C :: get multiple c 
C :: how to add a number before every line in c language 
C :: putting character in the begginig and end of sring C 
C :: email dev Microsoft Outlook 2007 items all aligned left or aligned wrong 
C :: vbl share price 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =