home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19353 < prev    next >
Encoding:
Text File  |  1993-01-07  |  1.1 KB  |  40 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!mcsun!ub4b!reks.uia.ac.be!derijkp
  3. From: derijkp@reks.uia.ac.be (Peter De Rijk)
  4. Subject: Problem with Turbo-C: calculating with pointers
  5. Message-ID: <1993Jan7.112219.578@reks.uia.ac.be>
  6. Organization: U.I.A.
  7. X-Newsreader: Tin 1.1 PL5
  8. Date: Thu, 7 Jan 1993 11:22:19 GMT
  9. Lines: 29
  10.  
  11. I am porting a program (working on different platforms such as VAX and DEC) to
  12. the PC. I am using Turbo C++ v.3.0. I compile using the huge memory model.
  13. I seem to have tracked down the problem (well, one of the problems.) I don't
  14. know what to do about it though. Here's a little program to illustrate the
  15. problem:
  16.  
  17. #include <alloc.h>
  18.  
  19. main()
  20. {
  21. char *pointer,*begin,*end;
  22. long size;
  23.  
  24. size=71800;
  25. pointer=(char *)farmalloc(size*sizeof(char));
  26. begin=pointer;
  27. end=pointer+size;
  28. printf("%p %p %ld",begin, end, end - begin);
  29. }
  30.  
  31. I would expect end - begin to return 71800. However it seems to return 6264.
  32. This is exactly 64K less.
  33. If this happens for all pointer calculations, I'm in big trouble.
  34. Any ideas to solve this.
  35.  
  36. All help is greatly appreciated.
  37.  
  38. Peter
  39.  
  40.