ericco@ssl.berkeley.edu (Eric C. Olson) (01/31/91)
Can anyone figure out why the a is not equal to b in the following program? And why the length of "test" is 3? I'm using LaserC. In other words how do I really get into binary mode (no translations). Thanks in advance, Eric #include <fcntl.h> /* test contains: 00000000 000d 0a ... */ main() { char *name = "test"; int fd; short a = 10, b; unlink(name); fd = creat(name, O_BINARY); if (fd > 0) { write(fd, &a, sizeof(a)); close(fd); fd = open(name, O_RDONLY | O_BINARY); if (fd > 0) { read(fd, &b, sizeof(b)); printf("a %d, b %d\n", a, b); } else { printf("couldn't reopen '%s'\n", name); } } else { printf("couldn't open '%s'\n", name); } } -- Eric ericco@ssl.berkeley.edu