b. Develop a C Application that implements a multithreaded
behaviour of
the CAT command in LINUX using exec calls. (use of built in CAT
command not
allowed.
#include<sys/types.h> #include<sys/stat.h> #include<stdio.h> #include<fcntl.h> main( int argc,char *argv[3] ) { int fd,i; char buf[2]; fd=open(argv[1],O_RDONLY,0777); if(fd==-argc) { printf("file open error"); } else { while((i=read(fd,buf,1))>0) { printf("%c",buf[0]); } close(fd); } }
sample input-output
$gcc –o prgcat.out prgcat.c //outputprogram name and c program name for compilation same of data using cat on a file student@ubuntu:~$cat > ff hello hai same output using our program on same file student@ubuntu:~$./prgcat.out ff hello hai
Get Answers For Free
Most questions answered within 1 hours.