string

#include<iostream.h>
void main()
{
char *str []={"lovely","hakeem"};
cout<<sizeof(str);
}

its size is 8;can any one tell me how?????
tnx
2*sizeof(char*) where sizeof(char*) is 4
str is pointer here?????
str is an array of two pointers to char
oh thanks...........i got it
but every pointer has a size of 2 bytes....yhen it should be 4......plz xplain
On 32 bit systems pointers are 32 bit integers, thus 4 bytes
Who taught you to include iostream.h? Find him and slap him(or her). Include iostream, not iostream.h
The size of pointers is variable depending on the system you're using.
quirkyusername said:
Who taught you to include iostream.h? Find him and slap him(or her). Include iostream, not iostream.h


I would guess that he's using an old book that still uses old headers. My book teaches it the same way.

Standard compilers require int main(). Using void main() is bad practice.
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
All pointers to data should have the same size, pointer to functions may be different
ok...tnx to all........good help..i will avoid that mistakes again....but we still studied it
Topic archived. No new replies allowed.