This might be an obvious question but I am a little unsure so I am going to go ahead and ask: When I create a pointer of array, and while declaring I initialize them, am I responsible of freeing them? (since I didnt have to call malloc I think the OS releases it..) And where are they saved, in the heap ? Example: char mypntrs[]= { "hi", "this", "is", "a", "test" }; (BTW, this is in C, I guess it applies to every language, the question I mean) Thanks.
On 13 Apr 2003 at 9:07, Raúl Gutiérrez Segalés wrote: Date sent: Sun, 13 Apr 2003 09:07:35 -0400 (PYT) From: Raúl Gutiérrez Segalés <rau@campoalto.edu.py> To: <suse-programming-e@suse.com> Subject: [suse-programming-e] Freeing memory
This might be an obvious question but I am a little unsure so I am going to go ahead and ask:
When I create a pointer of array, and while declaring I initialize them, am I responsible of freeing them? (since I didnt have to call malloc I think the OS releases it..) And where are they saved, in the heap ?
Example:
char mypntrs[]= { "hi", "this", "is", "a", "test" };
(BTW, this is in C, I guess it applies to every language, the question I mean)
Thanks.
I think what you actually want here is: char *mypntrs[] = { "hi", "this", "is", "a", "test" }; That's an array of pointers to char, initialised by the c-style strings. You don't have to free the memory, it will be freed when it goes out of scope. alan -- http://www.ibgames.net/alan Registered Linux user #6822 http://counter.li.org Winding Down - Weekly Tech Newsletter - subscribe at http://www.ibgames.net/alan/winding/mailing.html
participants (2)
-
alan@ibgames.com
-
Raúl Gutiérrez Segalés