home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!mcsun!ub4b!reks.uia.ac.be!derijkp
- From: derijkp@reks.uia.ac.be (Peter De Rijk)
- Subject: Problem with Turbo-C: calculating with pointers
- Message-ID: <1993Jan7.112219.578@reks.uia.ac.be>
- Organization: U.I.A.
- X-Newsreader: Tin 1.1 PL5
- Date: Thu, 7 Jan 1993 11:22:19 GMT
- Lines: 29
-
- I am porting a program (working on different platforms such as VAX and DEC) to
- 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.
- If this happens for all pointer calculations, I'm in big trouble.
- Any ideas to solve this.
-
- All help is greatly appreciated.
-
- Peter
-
-