Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!mips!apple!snorkelwacker!bloom-beacon!eru!hagbard!sunic!mcsun!tuvie!vmars!hp From: hp@vmars.tuwien.ac.at (Peter Holzer) Newsgroups: comp.os.msdos.programmer Subject: Re: HELP!! Turbo-C++ FAR POINTERS Message-ID: <1786@tuvie> Date: 31 Aug 90 10:18:31 GMT References: <0093BF75.AA852DC0@EA.USL.EDU> Sender: news@tuvie Lines: 40 johnson@EA.USL.EDU writes: >I was trying to use a very large array (char lines[1000][150];) using >Turbo-C++ on a 80-x86 based pc. I realized I needed a particular type >of pointer to address this thing, so I used a FAR pointer. However, >I did something wrong and real quickly compromised the integrity of the >FAT file on the hard-drive. (not very fun, I couldn't even boot up) >Needless to say I don't want to do this again. How can I declare and >address this array? I don't know about TC++, but in TC 2.0, you cannot declare such an array, you have to farmalloc it at run time. To address it you need a huge *, not a far * (Far pointer arithmetic wraps around after 64k). If you want your program to be a) fast and b) portable to other compilers/systems, leave the near, far, huge stuff out use the following code fragment: -------------------------------------------------------------------- char ** lines; int i; lines = malloc (1000 * sizeof (char *)); assert (lines); for (i = 0; i < 1000; i ++) { lines [i] = malloc (150); assert (lines [i]); } -------------------------------------------------------------------- (This should really go into a FAQ list, the question is asked every few weeks) -- | _ | Peter J. Holzer | Think of it | | |_|_) | Technische Universitaet Wien | as evolution | | | | | hp@vmars.tuwien.ac.at | in action! | | __/ | ...!uunet!mcsun!tuvie!vmars!hp | Tony Rand |