Q:

What's the size of char string array element?

I am learning c at the moment and I am slightly confused about the size element for a char string array element.
Take this example:
char *states[] = {
    "California", "Oregon",
    NULL, "Texas"
};

I wanted to see how I could get the size of the array, so I could count through it in a for loop. I found this calculation from some site to get the size of the array:
int size = sizeof(states) / sizeof(states[0]);

I'm a little confused, why is sizeof(states[0]) 8 bytes?  

A:

You have an array of pointers to characters. The total size of the array is
<number of elements> * <number of bytes for a char pointer>

The size of one of the members is the size of a char pointer (8 bytes on your system). So that gives you: 4*sizeof(char *)/sizeof(char *) Thus the number of elements in the array.
To see the length of the string at position 0 you need:
strlen(states[0]);

Which will give you the 10 you're expecting.

