Re: Pointer refering to an array of structutes?
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Sat, 1 Dec 2007 18:21:50 -0500
"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:11943AB3-72E6-4A21-AB38-3B9974AF4156@xxxxxxxxxxxxx
Igor, will your code work on raw C language, I have checked my
compiler's guide and as you must already know, "new" is not a valid
command, I only have calloc and malloc!
Doesn't change much:
S* p = malloc(100 * sizeof(S));
f(p, 100);
free(p);
1) S arr[100]; >>>> you create an array of "S" structures called
arr, right?
Right.
2) If you may refresh my memory, what does this line do? S* p = new
S[100]; ---Does it create an array of pointers on the heap?
No, it allocates an array of one hundred S structures on the heap, and
makes p point to the first element of this array.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: Pointer refering to an array of structutes?
- From: Giovanni Dicanio
- Re: Pointer refering to an array of structutes?
- References:
- Re: Pointer refering to an array of structutes?
- From: Igor Tandetnik
- Re: Pointer refering to an array of structutes?
- From: Robby
- Re: Pointer refering to an array of structutes?
- Prev by Date: Re: Murdering the C++ language.
- Next by Date: Re: Pointer refering to an array of structutes?
- Previous by thread: Re: Pointer refering to an array of structutes?
- Next by thread: Re: Pointer refering to an array of structutes?
- Index(es):
Relevant Pages
|