Re: problem with the code
jacob navia wrote:
The question is on topic and the answers are subject to review.
You passed up a chance to correct Richard Heathfield.
There is no such thing as "automatic scope".
--
pete
jacob navia wrote:
Richard Heathfield wrote:
>
I just can't understand why everybody competes in the
game:
>
Who does better ramu's homework?
>
You are NOT helping him.
>
>raashid bhatt said:
>>
>>
>Pretty much, yes. We can reduce the machine-specific nature of the
>reply by re-wording to something like "c has automatic scope, and so
>it is destroyed when control returns from func to its caller".
>>
>>
>>On Aug 24, 11:22 pm, ramu <ramu....@gmail .comwrote:
>>>Hi,
>>>Is there any problem with the following code?
>>>>
>>>Regards
>>>>
>>>char *func()
>>>{
>>>char c;
>>>return (&c);}
>>>>
>>>#include<std io.h>
>>>int main()
>>>{
>>>char *ch;
>>>ch = func();
>>>*ch = 'A';
>>>pritnf("%c", *ch);
>>>>
>>>}
>>as u see c is a local stack variable as soon a function returns the
>>its stack is cleared and it goes out of scope!
>>>Hi,
>>>Is there any problem with the following code?
>>>>
>>>Regards
>>>>
>>>char *func()
>>>{
>>>char c;
>>>return (&c);}
>>>>
>>>#include<std io.h>
>>>int main()
>>>{
>>>char *ch;
>>>ch = func();
>>>*ch = 'A';
>>>pritnf("%c", *ch);
>>>>
>>>}
>>as u see c is a local stack variable as soon a function returns the
>>its stack is cleared and it goes out of scope!
>Pretty much, yes. We can reduce the machine-specific nature of the
>reply by re-wording to something like "c has automatic scope, and so
>it is destroyed when control returns from func to its caller".
>>
I just can't understand why everybody competes in the
game:
>
Who does better ramu's homework?
>
You are NOT helping him.
>
You passed up a chance to correct Richard Heathfield.
There is no such thing as "automatic scope".
--
pete
Comment