Y
Yang Lee
Hi All,
I have two char pointers
char *a,*b;
a=(char *)malloc(10);
b=a; /*******/
so both pointers are looking at same mamory location
strcpy(a,"gates");
printf("%s",b);
Now I free pointer b;
free(b);
Then will pointer a be in existance or it will be also freed.
or if I free pointer a then will b point to same location.
Also
a=(char *)malloc(10);
strcpy(a,"gates");
free(a);
printf("%s",a); this still prints "gates " why is this happening
even after freeing the memory? should I write
a=NULL;
Please help my simple querries as it will help me a lot.
regards Lee
I have two char pointers
char *a,*b;
a=(char *)malloc(10);
b=a; /*******/
so both pointers are looking at same mamory location
strcpy(a,"gates");
printf("%s",b);
Now I free pointer b;
free(b);
Then will pointer a be in existance or it will be also freed.
or if I free pointer a then will b point to same location.
Also
a=(char *)malloc(10);
strcpy(a,"gates");
free(a);
printf("%s",a); this still prints "gates " why is this happening
even after freeing the memory? should I write
a=NULL;
Please help my simple querries as it will help me a lot.
regards Lee