Implement in C the cat Unix command using system calls
#include<fcntl.h>
#include<sys/stat.h>
#define BUFSIZE 1
int main(int argc, char **argv)
{
int fd1;
int n;
char buf;
fd1=open(argv[1],O_RDONLY);
printf("SuhritSolutions Printing Files\n");
while((n=read(fd1,&buf,1))>0)
{
printf("%c",buf);
/* or
write(1,&buf,1); */
}
return (0);
}
#include<fcntl.h>
#include<sys/stat.h>
#define BUFSIZE 1
int main(int argc, char **argv)
{
int fd1;
int n;
char buf;
fd1=open(argv[1],O_RDONLY);
printf("SuhritSolutions Printing Files\n");
while((n=read(fd1,&buf,1))>0)
{
printf("%c",buf);
/* or
write(1,&buf,1); */
}
return (0);
}
No comments:
Post a Comment