By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,670 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,670 IT Pros & Developers. It's quick & easy.

how to access array of struct to struct via pointers

P: 2
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
Share this Question
Share on Google+
3 Replies


RedSon
Expert 5K+
P: 5,000
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

P: 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
Expert 100+
P: 1,275
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.