jayjay
jayjay

Reputation: 1047

C initialising both an array and a pointer in struct to the same value

As the title, is it possible to initialize a pointer in a struct to point to the first element of an array that is also in the same struct?

struct foo
{
    int barr[12];
    int* barr_itt;
};

struct foo f = {{0}, /*.?.*/} 

Upvotes: 1

Views: 71

Answers (1)

2501
2501

Reputation: 25753

Yes, use the name of the variable

struct foo f = {{0}, f.barr} ;

Upvotes: 5

Related Questions