[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: read system call.
what made u say that ?? plz tell somethin about the
expected o/p & result u got.
one problem with the code is when u printf a string it
should end with a '/0'. but here it may not(ie buff)
if the file contains more than 9 chars. so i think u
r getting some gibrish o/p ??
_d ee p a k_
--- Lakshmi Gopinath <lakbala@xxxxxxxx> wrote:
> 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
>
>
>
> ---------------------------------------------
> LIP is all for free speech. But it was created
> for a purpose. Violations of the rules of
> this list will result in stern action.
>
>
>
=====
______________
_reply soon
_bye
__d ee p a k__
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/