Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Reference to a Structure (http://www.go4expert.com/forums/reference-structure-t9635/)

boschow 28Mar2008 21:57

Reference to a Structure

how do I reference a array to a structure, in a way when I change the value of that array I also affect the value of the structure, and when I affect the value of the structure I also affect the value of the array ?

I tryed to do something with pointer to the structure, since a pointer to a structure is very similar to array. I have done something like this :

typedef structu
  unsigned a1:1;
  unsigned a2:1;
  unsigned a3:1;
  unsigned a8:1;

int main()
  Coils objCoil;
  Coils *ptrCoil;
  ptrCoil = & objCoil;

  for(int i = 0; i < 8; i++)
      ptrCoil[i] = 1;


Thanks and best regards,

All times are GMT +5.5. The time now is 19:00.