Re: Strange array problem

From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 03/10/04


Date: Thu, 11 Mar 2004 00:39:36 +1100


"Sami Lakka" <sami.lakka@tut.fi> wrote in message news:c2n48r$t81$1@news.cc.tut.fi...
| Hi,
|
| I might be just missing something ridiculously simple but why does my arrays
| that
| are in private variables interfere with each other.
| Here is the output:
|
| 2 2 2 2
| 2 2 2 2
| 2 2 2 2
| 2 2 2 2
|
| 3 3 3 2 -- WHY THIS???
| 2 2 2 2
| 2 2 2 2
| 2 2 2 2

[snip]

Because, you are exceeding the array bounds, and
overwriting memory you don't own.

In your class you declare:

double matrix[3][3];

[snip]

Here you declare:

| const double MATRIX_SIZE = 4;

[snip]

Additionally, look through the magic numbers sprinkled
throughout your code, and you should immediately realise
where the errors are.

Cheers.
Chris Val



Relevant Pages

  • RE: Arrays - declaration, adding values to arrays and calculation
    ... Your declarations for bigdata and small data are fine, ... smalldata = Range.Resize ... I am a VBA beginner and would like to learn declaring arrays and using ... I want to declare three arrays BigData, ...
    (microsoft.public.excel.programming)
  • Re: initialising array of unknown size (newbie)
    ... help you if you copy the style of posting that is favoured here: snip ... will probably have to rewrite everything when you come to "wrap it up ... Note also that the code you cited does not really do 2D arrays. ... int i, j, k, row, col; ...
    (comp.lang.c)
  • Re: Performance of hand-optimised assembly
    ... DECLARE that those arrays are properly aligned and are suitable ... brittle machinery to DEDUCE that instead? ... usage of that variable it must be an int? ...
    (comp.lang.c)
  • Re: 2 queries- first day of month and reading zipped files directly off server
    ... It is generally considered bad style in Perl to declare all your ... > just decided to play with that one, instead of doing the subtractions ... or, if you have lots of arrays, ...
    (comp.lang.perl.misc)
  • Re: parameter incosistency
    ... fortran has always allowed variables to be used to declare the ... |>> | dimensions for dummy arrays. ... Early FORTRAN compilers required declarations like ... | function to do the subscript calculation, ...
    (comp.lang.fortran)