From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f43e6,bc16c150b1957917 X-Google-Attributes: gidf43e6,public X-Google-Thread: 1014db,5c666efe108c1065 X-Google-Attributes: gid1014db,public X-Google-Thread: 114917,5c666efe108c1065 X-Google-Attributes: gid114917,public X-Google-Thread: fac41,5c666efe108c1065 X-Google-Attributes: gidfac41,public X-Google-Thread: 114809,5c666efe108c1065 X-Google-Attributes: gid114809,public X-Google-Thread: 1108a1,5c666efe108c1065 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,5c666efe108c1065 X-Google-Attributes: gid103376,public X-Google-Thread: 109fba,5c666efe108c1065 X-Google-Attributes: gid109fba,public From: "Bradley A. Burns" Subject: Re: Help you C++ Debuggers! Date: 1997/01/21 Message-ID: <01bc07b5$1c546820$79ceaec7@sprynet.com>#1/1 X-Deja-AN: 211278004 references: <32DEF075.41C6@bme.ri.ccf.org> <1997Jan20.144447.5581@news> organization: CoreXtreme newsgroups: comp.lang.c,comp.lang.c++,comp.lang.asm.x86,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object,comp.software-eng Date: 1997-01-21T00:00:00+00:00 List-Id: This type of data capsule in C++ would best be declared dynamically. Look into the standard NEW and DELETE operators. You will need to use type pointers but that's not a problem at all. For example: float* f_var = new float[9000]; This will dynamically allocate an array of 9000 floats. You access these by using the standard array reference notation, for example: float f_temp = f_var[1280]; // returns 1 float value at array index 1280. // (actually 1279) since the index is 0 based. ...and remember, you can delete this singular array in one easy step: delete[] f_var; Now, all you have to do is apply it to a 3 dimensional array. By the way, the way you are doing it below, with some (most?) C++ compilers, even the smart ones, will reserve actual space in the .EXE file for 900,000 floats, therefore making your application much larger than it has to be, both in memory and on the hard disk. One other advantage of dynamic allocations is, say your application has many different areas (modules?) and you only need that large array of floats for one of those modules, you can perform a delete[] when the user leaves that module to go into another one. This, of course, is assuming that you're allocating these 900,000 locally (allocated and used only within a specific function or class), but somehow I think that this array is being allocated globally, for the entire application. Hope this helps, Brad. Ole-Hjalmar Kristensen FOU.TD/DELAB wrote in article ... > In article <1997Jan20.144447.5581@news> Gautier.DeMontmollin@maths.unine.ch (Gautier) writes: > > Macarthur Drake writes: > > I am in the mist of completing a major piece of code in C++. However I > > keep comming across a particularly difficult bug. Can you help? > > > > I am simply trying to declare a three D array: > > > > > > float objects[9000][10][10]; > > > > However, sometimes while compiling I get a strange compilation error > > like one of the following: > > > > 1. segmentation violation > > > The C compilers are known to have problems with multi-dim arrays. > Remember that C is near to a macro assembler (-> segmentation...)! > Remedy: > > You must use some pretty strange C compilers..... > > 1. > Make an 1-dim array and handle the 3 dims with multiplications > > Download gcc if your C compiler is broken. > > 2. > Download a good Ada compiler... N.B.: your message was posted in > comp.lang.ada . Was it premonitory ? ;)- > > Yes. >