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!