how to access array of struct to struct via pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kritikapoor
    New Member
    • Mar 2007
    • 2

    how to access array of struct to struct via pointers

    Hi,

    i have a structure like this:

    struct SC
    {
    const int address ;

    const int pad ;

    const int bits ;

    const int data ;

    };

    struct A
    {
    const SC* i0;
    const SC* i100;
    const SC* i125;
    };

    static const SC K0[] =
    {
    // Addr, Pads, Bits, Data

    { 0x1299, 0, 8, 0x00 },
    { 0x129a, 0, 8, 0xb0 },

    };
    static const SC K100[] =
    {
    // Addr, Pads, Bits, Data
    { 0x1299, 0, 8, 0x00 },
    { 0x129a, 0, 8, 0xb0 },

    };
    static const SC K125[] =
    {
    // Addr, Pads, Bits, Data
    { 0x1299, 0, 8, 0x00 },
    { 0x129a, 0, 8, 0x2c },

    };

    static const A a1=
    {
    K0, K100, K125,
    };

    How will i access K0,K100,K125 ?

    please guide me..
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    This looks like a homework assignment, because I can not think of any kind of application that would need this type of struct within a struct withing a struct ad infinitum.

    Comment

    • kritikapoor
      New Member
      • Mar 2007
      • 2

      #3
      Originally posted by RedSon
      This looks like a homework assignment, because I can not think of any kind of application that would need this type of struct within a struct withing a struct ad infinitum.
      No, This is not a home work assignment...It s a real time application problem.

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        HI,
        If you want to store structure value inside another structure then you should have a structure array.
        Code:
        static const A a1[3];
        a1[0]=K0;
        a1[1]=K100;
        a1[2]=K124;
        Then you can access the structures...
        Thanks
        Raghuram

        Comment

        Working...