N
Ned
char *foo(int idx)
{
switch (idx)
{
case 0:return "Hello";
case 1:return "Goodbye";
}
return "world";
}
Newby question.
I asked another question a few weeks ago about something similar. At that
time I wondered whether the memory allocated by a similar function for the
returned strings was ever disposed of during the lifetime of the program and
was told it wouldn't be.
I'd spotted some code like this in our application and wanted to get my
facts right before suggesting changes so that the fn returned pointers to
const char*s defined elsewhere.
Im just wondering about stacks. Was this memory allocated on the stack
(there's no heap available on our end system so I assume so)? If so, and
this memory's not removed, then how will the stack push and pops work for
items placed in the stack before the string?
(Ive no idea if this is a true ansii c question. Please dont tell me off if
it isnt, or at least point me nicely in a direction of a ng that can)
thanks
{
switch (idx)
{
case 0:return "Hello";
case 1:return "Goodbye";
}
return "world";
}
Newby question.
I asked another question a few weeks ago about something similar. At that
time I wondered whether the memory allocated by a similar function for the
returned strings was ever disposed of during the lifetime of the program and
was told it wouldn't be.
I'd spotted some code like this in our application and wanted to get my
facts right before suggesting changes so that the fn returned pointers to
const char*s defined elsewhere.
Im just wondering about stacks. Was this memory allocated on the stack
(there's no heap available on our end system so I assume so)? If so, and
this memory's not removed, then how will the stack push and pops work for
items placed in the stack before the string?
(Ive no idea if this is a true ansii c question. Please dont tell me off if
it isnt, or at least point me nicely in a direction of a ng that can)
thanks