Unix Operating System Lab Lab Practical Exercise-1
Unix Operating System Lab Lab Practical Exercise-1
LAB PRACTICAL
EXERCISE-1
2) Write a C program that makes a copy of a file using
standard I/O, and system calls.
AIM: C program that makes a copy of a file using standard I/O,
and system calls.
//SOURCE CODE
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
int f1, f2;
char buff[50];
long int n;
if(((f1 = open(argv[1], O_RDONLY)) == -1 ||
((f2=open(argv[2], O_CREAT | O_WRONLY | O_TRUNC,
0700))== 1))){
perror("problem in file");
exit(1);
}
while((n=read(f1, buff, 50))>0)