Edscott Wilson писал 2013-10-16 03:07: 

> I've been banging my head against the monitor for the past nine hours and 
> narrowed a problem down to the following.
> I've found that for certain data, the read() function will return a short 
> byte count. 
> 
> Take the following test file: http://xffm.org/test.dbh [1] and compile and 
> execute the following program:
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h>
> 
> int main(int argc, char **argv){
> int fd = open("test.dbh",O_RDWR);
> void *data = malloc(256);
> size_t bytes = read(fd, data, 256);
> printf("bytes read=%ldn", (long)bytes);
> printf("errno=%sn", strerror(errno));
> close(fd);
> FILE *f = fopen("test.dbh", "r");

Maybe:
FILE *f = fopen("test.dbh", "rb");

?

-- 
Regards, niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingw-w64/
___________________________________________________
Another online IDE: http://liveworkspace.org/
 

Links:
------
[1] http://xffm.org/test.dbh
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to