"hello" is a string literal and this is what the C standard says about
string literals:

>> The multibyte character sequence is then used to initialize an array of 
>> static storage duration and length just
>> sufficient to contain the sequence.

So memory will remain reserved for "hello" for the entire lifetime of
program.
Your program invokes undefined behavior because it causes a char
pointer to int conversion.

On Jul 27, 7:01 pm, Ankur Khurana <ankur.kkhur...@gmail.com> wrote:
> if i declare a string constant inside another function
> like let us say
> ,
> int how()
> {
>
> char *s="hello";
> return s;
>
> }
>
> so when how() get executed , the memory for hello will remain reserved or it
> can be allocated to others. Will it amount to memory leak ?
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to