On Tue Nov 22, 2005 at 19:47:51 -0600, [EMAIL PROTECTED] wrote:
>
>I find this interesting.
>
>This piece of code
>---------------------------------------
>char* somefunction()
>{
> char *string2 = "some words";
> return string2;
>}
>---------------------------------------
In this case you have create a point to some static data.
Here the memory is in the .rodata section.
>-----------------------------
>char* somefunction()
>{
> char string2[] = "some words";
> return string2;
>}
>--------------------------------------
>doesn't
In this case you have initiased a stack value to some initial
value. Here the memory is on the stack.
>
>>char *string2 = "some words\0";
>> string1 = (char *)calloc(strlen(string2 + 1), sizeof (char));
>
>strlen (string2 + 1) = strlen ("ome words");
>
>why do you want to do that?
>
Errr, that wasn't meant to be C, just saying that
strlen(string2 + 1) is equvilant to strlen("ome words");
Benno
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html