Struct assignment
- From: Grey Alien <grey@xxxxxxxxxxxxx>
- Date: Sat, 30 Jun 2007 17:43:26 +0100
If I have the ff struct:
struct A
{
unsigned int i;
char s[LONG_ENOUGH];
} a, b;
And use them in code like this:
a.i = 42 ;
strcpy(a.s,"test");
b.i = 100 ;
b = a ;
at this point, a (bitwise?) copy of a is made to b. Question is:
1). is b.s now ptr to a.s ? (I think so)
If so, what happens if for instance variable 'a' goes out of scope (?)
2). Does the compiler generate an implicit "memcpy" or "memmove" behind the scenes when it sees an assignment like this (to avoid dangling ptrs)?
.
- Follow-Ups:
- Re: Struct assignment
- From: Thomas Lumley
- Re: Struct assignment
- From: Flash Gordon
- Re: Struct assignment
- From: Malcolm McLean
- Re: Struct assignment
- Prev by Date: Re: reply the answer
- Next by Date: Re: segmentation fault
- Previous by thread: segmentation fault
- Next by thread: Re: Struct assignment
- Index(es):
Relevant Pages
|
|