468,121 Members | 1,570 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,121 developers. It's quick & easy.

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..
Mar 30 '07 #1
3 1538
RedSon
5,000 Expert 4TB
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.
Mar 30 '07 #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.
No, This is not a home work assignment...Its a real time application problem.
Apr 2 '07 #3
gpraghuram
1,275 Expert 1GB
HI,
If you want to store structure value inside another structure then you should have a structure array.
Expand|Select|Wrap|Line Numbers
  1. static const A a1[3];
  2. a1[0]=K0;
  3. a1[1]=K100;
  4. a1[2]=K124;
  5.  
Then you can access the structures...
Thanks
Raghuram
Apr 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

20 posts views Thread by fix | last post: by
32 posts views Thread by Carson | last post: by
7 posts views Thread by Frank M. | last post: by
10 posts views Thread by Adam Warner | last post: by
5 posts views Thread by Stijn van Dongen | last post: by
2 posts views Thread by Simon Morgan | last post: by
7 posts views Thread by Kathy Tran | last post: by
15 posts views Thread by Paminu | last post: by
20 posts views Thread by Cyn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.