How can I get the size of this?
- From: "Carl" <carl8421@xxxxxxx>
- Date: Fri, 22 Apr 2005 14:25:07 +0800
Hello,All!
I am now having a problem at using sizeof() function to ensure how many
items I have in my programe, the source code likes this:
const char* Data[]={"abc","bcd","cde","def","wot","shame"};
and now I were trying to use sizeof() to get the size:
int szData = sizeof( Data ) / sizeof( Data[0] );
but now the system told me that was illegal sizeof() caller, then I did some
change like this:
int szData = sizeof( (char*) Data )/ sizeof( Data[0] );
and
int szData = sizeof( (char**) Data )/ sizeof( Data[0] );
To my surprise, both of them were just get the size of the pointer, here in
my programme, they are 4, I mean sizeof( (char**) Data ),sizeof( (char*)
Data ) and sizeof( Data[0] ). so we can sure that they are all just a
pointer. How can I get teh correctly size of this function call and making
my szData = 6 ?
Is there anybody who can tell me that?
Thanks in advance!
.
- Follow-Ups:
- Re: How can I get the size of this?
- From: Carl
- Re: How can I get the size of this?
- From: David Webber
- Re: How can I get the size of this?
- Prev by Date: Re: nested functions in VC++
- Next by Date: Re: subtracting two pointers to same function ?
- Previous by thread: nested functions in VC++
- Next by thread: Re: How can I get the size of this?
- Index(es):
Relevant Pages
|
Loading