[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

read system call.



Hello Everybody,

I wrote a simple program to read some data from an ordinary text file usng
the read system call. but  it does not seem to be working. cud someone pls
help me out


#include<fcntl.h>
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<errno.h>

int main()
{
   int fd,count;
   char buff[10];
   if (fd = (open("/root/data",O_RDONLY,0) < 0))
    {
      printf("\n %s",strerror(errno));
      exit(-1);
    }
   bzero(buff,10);
   while(count = (read(fd,buff,sizeof(buff))) > 0)
       {
         printf("\n %s ",buff);
         printf("\n %d",count);
         bzero(buff,10);
       }
 }






regards ,
lakshmi