Web lists-archives.org

[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