Computer Science Canada "free" function for simple array. |
Author: | MysticVegeta [ Mon Nov 07, 2005 7:54 pm ] |
Post subject: | "free" function for simple array. |
i am aware of the "free" function used to "free"/"empty" a flexible array, i was wondering if we could do the same with regular array. |
Author: | beard0 [ Mon Nov 07, 2005 9:56 pm ] |
Post subject: | Re: "free" function for simple array. |
MysticVegeta wrote: i am aware of the "free" function used to "free"/"empty" a flexible array, i was wondering if we could do the same with regular array.
Why not just try, and see if it works? |
Author: | MysticVegeta [ Mon Nov 07, 2005 11:29 pm ] |
Post subject: | |
I did: Quote: Array grid is not flexible and hence cannot be 'free'ed |
Author: | beard0 [ Tue Nov 08, 2005 12:36 am ] | ||
Post subject: | |||
Then why did you ask? I could understand "Why can't..." In which case the answer would be because free varName is a shorthand for
which only works with flexible arrays, as they are the only ones whose size is flexible. |
Author: | do_pete [ Tue Nov 08, 2005 1:49 pm ] | ||
Post subject: | |||
If you want to make all the things in a variable equal 0 you can use xomething like this:
|
Author: | MysticVegeta [ Tue Nov 08, 2005 2:03 pm ] |
Post subject: | |
No, I want them equal to nothing, nothing so that grid(x, y) returns an error of "No value for variable". Just like we can do in flexible arrays. I thought it could be done, guess i was wrong. |
Author: | do_pete [ Tue Nov 08, 2005 2:49 pm ] |
Post subject: | |
when you declare you array then there will be no value for variable |
Author: | Tony [ Tue Nov 08, 2005 3:06 pm ] | ||
Post subject: | |||
turing doesn't appear to allow you to drop a non-dynamically allocated variable. The best way would be to include the array in a type, and use a pointer to that type. You could free a pointer afterwards. Or if you're feeling adventurous, try the following out
|
Author: | beard0 [ Tue Nov 08, 2005 4:10 pm ] |
Post subject: | |
Tony wrote: Or if you're feeling adventurous, try the following out
Fun, I hadn't really had the chance to try this out before. I'll have to play with this. |
Author: | MysticVegeta [ Tue Nov 08, 2005 7:13 pm ] |
Post subject: | |
do_pete wrote: when you declare you array then there will be no value for variable
I meant after changing its value. |