Dec 24, 2010 at 5:37pm UTC
#include<iostream.h>
void main()
{
char *str []={"lovely","hakeem"};
cout<<sizeof(str);
}
its size is 8 ;can any one tell me how?????
tnx
Dec 24, 2010 at 5:49pm UTC
2*sizeof (char *)
where sizeof (char *)
is 4
Dec 24, 2010 at 6:07pm UTC
str is an array of two pointers to char
Dec 24, 2010 at 6:17pm UTC
oh thanks...........i got it
Dec 25, 2010 at 8:12am UTC
but every pointer has a size of 2 bytes....yhen it should be 4......plz xplain
Dec 25, 2010 at 4:15pm UTC
On 32 bit systems pointers are 32 bit integers, thus 4 bytes
Dec 25, 2010 at 6:16pm UTC
Who taught you to include iostream.h? Find him and slap him(or her). Include iostream, not iostream.h
Dec 25, 2010 at 9:27pm UTC
I didn't even notice that =P yeah include iostream, and use int main(). Also, pointers aren't always a fixed size, even on the same system, they are when they point to an ordinary data type like int or bool or float but a pointer to a member function for example could be a different size.
Last edited on Dec 25, 2010 at 9:32pm UTC
Dec 25, 2010 at 9:59pm UTC
All pointers to data should have the same size, pointer to functions may be different
Dec 26, 2010 at 8:06am UTC
ok...tnx to all........good help..i will avoid that mistakes again....but we still studied it