/* Write a c program using system calls to display content of file. Kindly add header files like :stdio.h,sys/types.h, sys/stat.h, unistd.h,string.h,fcntl.h */
int main(int argc, char *argv[])
{
int fd=0,r=0,i=0;
char buf[1024];
if(argc >= 2)
{
for(i=1;i
{
fd=open(argv[i],O_RDONLY);
if(fd == -1)
{
printf("file not exist");
}
else
{
while((r=read(fd,buf,1024))>0)
write(1,buf,r);
}
}
}
else
{
printf("enter appropriate arguments");
}
return 0;
}
int main(int argc, char *argv[])
{
int fd=0,r=0,i=0;
char buf[1024];
if(argc >= 2)
{
for(i=1;i
{
fd=open(argv[i],O_RDONLY);
if(fd == -1)
{
printf("file not exist");
}
else
{
while((r=read(fd,buf,1024))>0)
write(1,buf,r);
}
}
}
else
{
printf("enter appropriate arguments");
}
return 0;
}
Comments
Post a Comment