home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.os.msdos.programmer:9317 comp.lang.c:13602
- Newsgroups: comp.os.msdos.programmer,comp.lang.c
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!eng.ufl.edu!manta!zzang
- From: zzang@stat.ufl.edu (Zhuo Zang)
- Subject: Re: BC++2.0 lseek problem(ALSO:lseek() question)
- Message-ID: <1992Sep13.011428.25100@eng.ufl.edu>
- Originator: zzang@manta
- Sender: news@eng.ufl.edu (Usenet Diskhog System)
- Organization: University of Florida
- References: <1992Sep12.235241.23213@eng.ufl.edu>
- Distribution: usa
- Date: Sun, 13 Sep 92 01:14:28 GMT
- Lines: 57
-
- Hello,
- I have a typo in the code, so there is no
- question in comp.lang.c .
- the bug in BC++2.0 is still unsolved.
-
- In article <1992Sep12.235241.23213@eng.ufl.edu> zzang@stat.ufl.edu (Zhuo Zang) writes:
- >Hello,
- >the following program using lseek will
- >give different results in BC++2.0 than
- >that of in UNIX.
- >the BC++2.0 will print the last character twice.
- >
- >------- foo.c ----------
- >/* use bcc -DMSDOS foo.c to compile in BC++i
- > use cc foo.c to compile under UNIX */
- >#include <stdio.h>
- >#include <fcntl.h>
- >#ifdef MSDOS
- >#include <io.h>
- >#else
- >#include <sys/file.h>
- >#endif
- >
- >char *sp, buf[BUFSIZ];
- >int fd;
- >int get(int fd, long pos, char *buf, int n);
- >
- >int main()
- >{
- > sp = buf;
- > fd = open("foo.c", O_RDONLY, 0);
- > get(fd, 3, sp, 20);
- >/* I have question here, where does the sp point now?
- > please notice the assignment sp = '\0', and the output
- there is a typo here, should be *sp = '\0', sorry.
- no question! :-)
- > of the program */
- > puts(sp);
- > sp = '\0';
- > puts(buf);
- > return 0;
- >}
- >
- >int get(int fd, long pos, char *buf, int n)
- >{
- > if (lseek(fd, pos, 0) >= 0)
- > return read(fd, buf, n);
- > else
- > return -1;
- >}
- >
-
-
- --
- Zhuo Zang[~{j0WA~}]
- Department of Statistics
- University of Florida Email: zzang@stat.ufl.edu
-