| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How can you do this? I have tried
delete state[]; and delete []state; and for (i=0; i < number; i++) state[i] = 0; delete state[i]; What am I doing wrong? ![]() |
|
#2
|
||||
|
||||
|
state = new char[x];
delete state[]; ^^ That's what it should look like. What makes you sure that it is indeed not being deallocated?
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips. ![]() |
|
#3
|
|||
|
|||
|
I get a weird error in the destructor (that's where I am deallocating the memory). I'll try it again and post the exact code and the exact error.
|
|
#4
|
|||
|
|||
|
If you have declared the state as a dynamically, then just write free(state)
or if u have written the function - delete for deleting then just pass the state as a parameter. |
|
#5
|
|||
|
|||
|
hey r u there?
still having the probelm? If you have declared the state as a dynamically, then just write free(state) or if u have written the function - delete for deleting then just pass the state as a parameter. |
|
#6
|
|||
|
|||
|
can u type the whole code?
|
|
#7
|
|||
|
|||
|
if the state is a pointer then it would work i have done that
|
|
#8
|
|||
|
|||
|
hey r u using c++?
then u have to delete the state and then write state = null; |
|
#9
|
||||
|
||||
|
Isn't the same true of C as-well as C++. The memory is freed so it can be reused by the program but until the memory is written over the old value exists
.Mark. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Deallocate Dynamically-declared array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|