[Mingw-users] how to use the read/write
- Date: Mon, 5 May 2008 16:10:13 +0800
- From: "yu jie" <yujie052@xxxxxxxxx>
- Subject: [Mingw-users] how to use the read/write
Hi, all:
The size of a.pdf is about 24M. I get weird result from the following code, the read function in while condition only returns twice.
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main()
{
int fd, i = 0;
ssize_t ret;
char buffer[4*1024];
fd = open("d:/a.pdf", O_RDONLY);
if (fd < 0) {
printf("can't open\n");
return 0;
}
while ((ret = read(fd, buffer, 4*1024)) > 0) {
printf("%d, %d\n", ret, ++i);
}
close(fd);
return 0;
}
Best wishes.
Kevin
------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________ MinGW-users mailing list MinGW-users@xxxxxxxxxxxxxxxxxxxxx You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users
- Follow-Ups:
- Re: [Mingw-users] how to use the read/write
- From: Tor Lillqvist
- Re: [Mingw-users] how to use the read/write
- Prev by Date: Re: [Mingw-users] GCC 4.3.0 20080502 (alpha) Released - Please help us test it!
- Next by Date: Re: [Mingw-users] how to use the read/write
- Previous by thread: [Mingw-users] GCC 4.3.0 20080502 (alpha) Released - Please help us test it!
- Next by thread: Re: [Mingw-users] how to use the read/write
- Index(es):