Thursday, 4 December 2014


#include"myHeader.h"
main(int argc,char **argv)
{
int ret,i;
char readbuf[30];
ret=open(argv[1],O_RDONLY);
if(argc!=2)
printf("enter correct arguments\n");
if(ret==-1)
{
perror("open");
return;
}
printf("file description:%d\n",ret);
while((read(ret,readbuf,30)))
printf("%s",readbuf);
//readbuf[20]='\0';
}
OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ cc ex34.c
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out madan
file description:5
welcome madan reddy
hyderabad
always truth wins
y
hyderabad