All fixed! Thanks!
All fixed! Thanks!
Last edited by bond_006; 03-24-2010 at 10:57 AM.
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).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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