Please clear my doubt
From: Yang Lee (yang__lee_at_ausi.com)
Date: 11/30/03
- Next message: Robert Stankowic: "Re: Please clear my doubt"
- Previous message: Servé Lau: "Re: Is C99 the final C?"
- Next in thread: Robert Stankowic: "Re: Please clear my doubt"
- Reply: Robert Stankowic: "Re: Please clear my doubt"
- Reply: James Hu: "Re: Please clear my doubt"
- Reply: Simon Biber: "Re: Please clear my doubt"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Nov 2003 08:55:00 +0000 (UTC)
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
-- Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
- Next message: Robert Stankowic: "Re: Please clear my doubt"
- Previous message: Servé Lau: "Re: Is C99 the final C?"
- Next in thread: Robert Stankowic: "Re: Please clear my doubt"
- Reply: Robert Stankowic: "Re: Please clear my doubt"
- Reply: James Hu: "Re: Please clear my doubt"
- Reply: Simon Biber: "Re: Please clear my doubt"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|