Re: How can I get the size of this?
- From: "John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx>
- Date: Sat, 23 Apr 2005 03:08:10 +1000
"David Webber" <dave@xxxxxxxxxxxxxxxxxxx> wrote in message news:e6%23IwAxRFHA.3704@xxxxxxxxxxxxxxxxxxxx
In these matters "typedef" is often your friend!
LPCSTR is already typedef'd as "const char *", so use it.
LPCSTR Data[]={"abc","bcd","cde","def","wot","shame"};
makes Data unambiguously an array of LPCSTRs, and
int nSize = sizeof Data;
should get you the answer 24 (six times sizeof LPCSTR).
I can't see why the use of a typedef should make the slightest difference --- and on my system (VC++ 7.1) it doesn't. Indeed the OP's original code works fine. The following gives a value of 6 for szData.
int main()
{
const char* Data[]={"abc","bcd","cde","def","wot","shame"};
int szData = sizeof( Data ) / sizeof( Data[0] );
return 0;
}--
John Carson
.
- Follow-Ups:
- Re: How can I get the size of this?
- From: David Webber
- Re: How can I get the size of this?
- References:
- How can I get the size of this?
- From: Carl
- Re: How can I get the size of this?
- From: David Webber
- How can I get the size of this?
- Prev by Date: Re: 3rd party library in VC++/MFC
- Next by Date: Re: How can I get the size of this?
- Previous by thread: Re: How can I get the size of this?
- Next by thread: Re: How can I get the size of this?
- Index(es):
Relevant Pages
|