Professional Documents
Culture Documents
Lab Journal 8
Student Name
AMMARA BABAR
Enrolment No.
01-235191-043
Class and Section
4B
}
printf("copied successfully :\n");
close(fd);
close(fd1);
return(0);
}
Output:
Task # 2: Write a program in C to demonstrate file read operation from command line i.e cat
operation.
Copy from one file and paste on screen using system calls open, read and write.
Program:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#define buffsize 1024
int main()
{
int fd ,l;
char buff[buffsize] ;
l=read(fd,buff,buffsize);
while (l >0)
{
write(1,buff,l);
l=read(fd,buff,buffsize);
}
close(fd);
return(0);
}
Output:
closedir(dr);
return 0;
}
Output:
For your help in 3rd task: For functions, algorithm and library help see the online lecture video that has
been provided to you. It covers this in detail.