All fixed! Thanks!
Printable View
All fixed! Thanks!
1) The `new' operator doesn't return `null' so checking for `null' isn't useful.
2) You aren't assigning any values to the array. (Which is a damned good thing considering that you are guaranteed to access memory you don't own.)
Soma
that rand() call is not in a good placeCode:fill a with random numbers
for ( int i = 0 ; i < size ; i++ )
array1[ rand() ] ;
and i thought srand time null, not 0 ? i dunno if that makes much difference though, i just sticks wit wot i knows on the rand num generation
Please don't delete your posts as soon as you think you've got an answer:
- your answer might be wrong (no one else can check or contribute)
- all the replies are meaningless
- no one else can learn (how selfish of you).
One relevant part is in the second response.
That code is other relevant bit.Code:int * array1;
// ...
array1 = new int[size]; if(!array) exit(1);
Maybe we can get an administrator to "repair" the context of the original post.
Soma