Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!agate!sunspot.berkeley.edu!ericco From: ericco@ssl.berkeley.edu (Eric C. Olson) Newsgroups: comp.sys.atari.st.tech Subject: creat, open, read & write Message-ID: Date: 31 Jan 91 08:31:55 GMT Sender: usenet@agate.berkeley.edu (USENET Administrator) Distribution: comp Organization: CEA @ UC Berkeley, Berkeley, CA, USA. Lines: 38 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 /* 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