home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!newsserver.jvnc.net!rutgers!mcdhup!src4src!wozzle!alane
- From: alane@wozzle.linet.org (J. Alan Eldridge)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with Turbo-C: calculating with pointers
- Message-ID: <qN76wB6w165w@wozzle.linet.org>
- Date: 10 Jan 93 16:36:37 GMT
- References: <1993Jan7.112219.578@reks.uia.ac.be>
- Organization: Disorganization
- Lines: 34
-
- derijkp@reks.uia.ac.be (Peter De Rijk) writes:
-
- > I am porting a program (working on different platforms such as VAX and DEC) t
- > the PC. I am using Turbo C++ v.3.0. I compile using the huge memory model.
- > I seem to have tracked down the problem (well, one of the problems.) I don't
- > know what to do about it though. Here's a little program to illustrate the
- > problem:
- >
- > #include <alloc.h>
- >
- > main()
- > {
- > char *pointer,*begin,*end;
- > long size;
- >
- > size=71800;
- > pointer=(char *)farmalloc(size*sizeof(char));
- > begin=pointer;
- > end=pointer+size;
- > printf("%p %p %ld",begin, end, end - begin);
- > }
- >
- > I would expect end - begin to return 71800. However it seems to return 6264.
- > This is exactly 64K less.
-
- You have to explicitly declare huge pointers, even in huge model. Make
- your var definitions:
-
- char huge *pointer, huge *begin, huge *end;
-
- This should clear things up for you. BTW It's in the manual... somewhere...
-
- alane@wozzle.linet.org (J. Alan Eldridge)
- Fido: The University of Walamaloo 1:272/38.473
-