1

我正在编写一个文件传输程序。但是由于某种原因,尽管不在文件末尾,但仍在pread返回。0任何人都可以看看我的代码并看到问题吗?它与fread.

        int file;
        unsigned int size = selfp->intdata;
        file=open(str, O_RDONLY); 
        char buf[1024];

        printf("filename = %s \n", str);//prints file name requested
        printf("buffer = %s \n", buf);//prints nothing currently
        printf("offset = %d \n",atoi(chunkIndex)*CHUNK);//prints 0 for first chunk
        printf("CHUNK = %d \n", CHUNK);//prints 1024
        int myoffset = atoi(chunkIndex)*CHUNK; 
        int dataSize=pread(file, buf, sizeof buf, myoffset);
        printf("%d\n", dataSize);//returns 0

        close(file);

谢谢!

4

0 回答 0