Structure having pointers
- From: sam_cit@xxxxxxxxxxx
- Date: Sun, 29 Jul 2007 03:20:00 -0700
Hi,
I have the following Struct,
Struct Sample
{
int i;
char *p;
};
int main()
{
Sample a;
a.p = malloc(10);
Sample b;
b = a;
}
Now i think a shallow copy is done and if i destry only on the object
there would be a dangling pointer.
How do i overcome this problem as C structures don't support
functions?
Thanks in advance!!!
.
- Follow-Ups:
- Re: Structure having pointers
- From: Richard Heathfield
- Re: Structure having pointers
- From: Malcolm McLean
- Re: Structure having pointers
- From: santosh
- Re: Structure having pointers
- From: AnticitizenOne
- Re: Structure having pointers
- Prev by Date: Re: is malloc thread-safe??
- Next by Date: Re: function for clockticks since 1980?
- Previous by thread: can preprocessor automatically make N array elements?
- Next by thread: Re: Structure having pointers
- Index(es):
Relevant Pages
|