*Temp=a;*\\ assigns the address stored in 'a' to 'temp';

*a=malloc(strlen(p) + 1); \\*value of 'a' changed.*  '*a' points to
different address ,but value stored in 'temp' does not change.so now 'a' and
'temp' points to different address.

hence
*strcpy(a,p); *does not change the content of memory location  pointed by
temp.

On Tue, Jul 26, 2011 at 12:19 AM, swetha rahul <swetharahu...@gmail.com>wrote:

> *void main()
> *{*
> int i;
> char *a="String";
> char *p="New String";
> char *Temp;
> Temp=a;
> a=malloc(strlen(p) + 1);
> strcpy(a,p);
> p = malloc(strlen(Temp) + 1);
> strcpy(p,Temp);
> printf("(%s, %s)",a,p);
> free(p);
> free(a);
> } *
> *
> *
> *
> *
> *output is (New String,String)*
> *
> *
> *how does Temp retains "String" even after New String is copied in a? Is
> it not pointing to the same location?pls explain*
>
> --
> 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.
>

-- 
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