Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!oddjob!gargoyle!mason From: mason@gargoyle.UChicago.EDU (Tony Mason) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: Assigning to Pointers Message-ID: <642@gargoyle.UChicago.EDU> Date: Thu, 30-Apr-87 10:35:01 EDT Article-I.D.: gargoyle.642 Posted: Thu Apr 30 10:35:01 1987 Date-Received: Sat, 2-May-87 09:05:57 EDT References: <3537@vrdxhq.UUCP> <2248@tekgvs.TEK.COM> Reply-To: mason@gargoyle.uchicago.edu.UUCP (Tony Mason) Organization: U. of Chicago, Computer Science Dept. Lines: 41 Xref: mnetor comp.sys.ibm.pc:3650 comp.lang.c:1988 >>This may be a dumb question, but could someone please explain >>to me how I assign an absolute address to a pointer to an array? >>... >>I'm using MSC 4.0 >> >You have to remember that addresses of "far" data structures are longs and >not ints. > >For SMALL or MEDIUM memory models (i.e., one data segment), you can say > >int far *aa[]; /* aa is a far pointer to an array of ints */ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unless my understanding of C (and of those around me) has just gone out the window, that is an array of far pointers to integers. To make the delcaration fit the comment it should be: int far *aa; /* aa is a far pointer to an array of ints */ Now you just use integer arithmetic to acces elements in the array (eg. *(aa + 4) would be the fifth integer in the array). To make the comment match the declaration : int far *aa[]; /* aa is an array of far pointers to integers */ Now, to access an integer, you would use something like *aa[4] to access the integer pointed at by the fifth element of the pointer array. Finally, if you use the undefined array size syntax, you are defining something that must be external (or in a function declaration list). Whether or not the compiler should accept this at all is quite suspect (at least to me) without an extern in front. As for using far, that is only necessary when you are using (1) any model with restricted data size AND (2) accessing a data structure outside the normal data segment. In line with the type of question asked, this is probably NOT what was being asked. I think the confusion in this case was with pointer declarations, not access problems. Tony Mason Univ. of Chicago, Dept. of C.S. ARPA: mason@gargoyle.uchicago.edu UUCP: ...ihnp4!gargoyle!mason