In C how do you access a variable in a struct that's in a pointer array? -


typedef struct {     employeet *employees;     int nemployees; } *payrollt;  typedef struct {     string name; } *employeet; 

i need without accessing array:

employeet e = payroll.employees[i]; 

but gives me error(expected identifier before '(' token) :

employeet e = payroll.(*(employee+i)); 

before struct's interchange employees[i] , *(employee+i)

why need avoid array syntax?

*(ptr+offset) == ptr[offset], strictly, every time.

you have no performance penalty , array syntax clearer.


edit: got real crux of problem.

if payroll (in example) pointer type, need use arrow operator instead of dot operator:

payroll->employees[0] 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -