Doubt regarding usage of array as a pointer in C

Posted by Som on Stack Overflow See other posts from Stack Overflow or by Som
Published on 2011-02-17T05:36:59Z Indexed on 2011/02/17 7:25 UTC
Read the original article Hit count: 127

Filed under:
|
|
|

For eg. I have an array of structs 'a' as below:

struct mystruct{
    int b
    int num;
};
struct bigger_struct {
   struct my_struct a[10];
}

struct bigger_struct *some_var;

i know that the name of an array when used as a value implicitly refers to the address of the first element of the array.(Which is how the array subscript operator works at-least) Can i know do the other way around i.e if i do:

some_var->a->b, it should be equivalent to some_var->a[0]->b, am i right? I have tested this and it seems to work , but is this semantically 100% correct?

© Stack Overflow or respective owner

Related posts about c

    Related posts about arrays