home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / msdos / programm / 11911 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.8 KB  |  65 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!hshulman
  3. From: hshulman@magnus.acs.ohio-state.edu (Harvey G Shulman)
  4. Subject: Re: structures >64K
  5. Message-ID: <1993Jan8.153555.21210@magnus.acs.ohio-state.edu>
  6. Keywords: struct, huge
  7. Sender: news@magnus.acs.ohio-state.edu
  8. Nntp-Posting-Host: top.magnus.acs.ohio-state.edu
  9. Organization: The Ohio State University
  10. References: <1993Jan8.135612.14930@aau.dk>
  11. Date: Fri, 8 Jan 1993 15:35:55 GMT
  12. Lines: 51
  13.  
  14. To: psykseth@aau.dk
  15. Subject: Re: structures >64K
  16. Newsgroups: comp.os.msdos.programmer
  17. In-Reply-To: <1993Jan8.135612.14930@aau.dk>
  18. Organization: The Ohio State University
  19. Cc: 
  20. Bcc: 
  21.  
  22. Seth:  the code below compiled and ran without error under
  23. turbo c's huge model.  Make sure you select this model on
  24. the compiler option menu.  
  25.  
  26. It would probably work as well under the
  27. large model with the pointer declaration changed to
  28. yynew  huge *yycrank, j;
  29.  
  30. I wasn't able to come up with a good way to initialize the
  31. allocated records but the technique below of initializing the
  32. fields of another record, j, and then assigning it to the record
  33. pointed to by yycrank seemed to work.
  34.  
  35.  
  36. #include  <stdio.h>
  37. #include  <stdlib.h>
  38. #include  <alloc.h>
  39.  
  40. void main()
  41. {
  42. int  i;
  43. typedef struct yynew {int current, advance;} yynew;
  44. yynew  *yycrank, j;
  45.  
  46. /* in the allocation statement I could not see why you used 20000L.
  47.    after all 20000 is 20000, isn't it? */
  48.  
  49. yycrank = farmalloc(20000 * sizeof(yynew));
  50. for (i = 0; i < 20000; i++)
  51.  { j.current = 0;
  52.     j.advance = i;
  53.     *(yycrank+i) = j ;
  54.  };
  55. }
  56.  in the above loop I tried several variants of assignment to the
  57.  fields of yycrank's records without success.  Maybe someone else can
  58.  describe how to do such things as   *(yycrank+i).current = 0
  59.  
  60.  
  61. -- 
  62. Harvey Shulman
  63. Ohio State University, Dept of Psychology
  64. 614 292-2759 / h.shulman@osu.edu
  65.