Aim: Write a program
for cat command.
Program:
#include<stdio.h>
#include<fcntl.h>
#define buf 2048
int main(int argc, char *argv[])
{
          int
fd;
          char
buf1[buf];
          fd=open(argv[1],O_RDWR);
          read(fd,buf1,buf);
          printf(“%s”,buf1);
}
Output:
$ cc cat.c
$ ./a.out cat.txt
 
No comments:
Post a Comment