Mail Archives: djgpp/1999/01/15/08:39:17
On Fri, 15 Jan 1999, Konstanty wrote:
> In a program of mine I have two arrays initilised with "new".
>
> eg
> int *Map;
> Map=new int [225];
>
> The problem is that when I write to one array it corrupts the other with
> the same data.
>
> Is this because they were not initilised properly?
> If so how can you check if an array is initilised properly?
It seems that you tried to access the data behind the limit of the first
array:
A = new int[10];
B = new int[10];
A[15] = 1; // this corrupts some data, possibly B's.
^^
You should also check if operator new didn't return NULL pointer.
--------------------\ Wojciech Piechowski /----------------------------
Student informatyki \ voyt AT ds2 DOT pg DOT gda DOT pl / Student of computer science
Politechnika Gdanska \________________/ Technical University of Gdansk
- Raw text -