Search found 18 matches
- Wed Oct 06, 2010 3:57 pm
- Forum: Programming Discussion
- Topic: how literals are stored in memory
- Replies: 19
- Views: 2666
Re: question about passing string literals to functions
Since you're just passing a pointer to the string, only the pointer gets removed when the function ends. So if you didn't deallocate the memory or reference it then it would be leaked right? also: would these two functions act the same way? void function(char* string); void function(char string[]);
- Wed Oct 06, 2010 4:30 am
- Forum: Programming Discussion
- Topic: how literals are stored in memory
- Replies: 19
- Views: 2666
Re: question about passing string literals to functions
would the function ending cause them to go out of scope?ismetteren wrote:My guess is that they are declared on the stack and get deleted when they go out of scope.
- Wed Oct 06, 2010 4:21 am
- Forum: Programming Discussion
- Topic: how literals are stored in memory
- Replies: 19
- Views: 2666
how literals are stored in memory
When you pass a string literal to a function like this void function(char* string); what happens to the memory allocated to store the literal? the reason I ask is because as far as I understand it, the pointer 'string' would be deleted after 'function' ends. so if you didn't assign another pointer t...