1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Reference to a Structure

Discussion in 'C' started by boschow, Mar 28, 2008.

  1. boschow

    boschow New Member

    Joined:
    Feb 22, 2007
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    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 :
    Code:
    typedef structu
    {
       unsigned a1:1;
       unsigned a2:1;
       unsigned a3:1;
       .
       .
       .
       unsigned a8:1;
    }Bits;
    
    int main()
    {
       Coils objCoil;
       Coils *ptrCoil;
       ptrCoil = & objCoil;
    
       for(int i = 0; i < 8; i++)
       {
           ptrCoil[i] = 1;
       }
    
    }
    
    Thanks and best regards,
    BoSCHoW.
     
    Last edited: Mar 28, 2008

Share This Page