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

structures in c

P: 63
typedef struct structure1{
int i;
int *j;
} struct_name1;

typedef struct structure2 {
int k;
struct_name1 *ptr;
} struct_name2 , *ptr2;

I need to know how to access pointer' j 'with *ptr2;
Mar 19 '07 #1
Share this Question
Share on Google+
2 Replies


P: 39
Expand|Select|Wrap|Line Numbers
  1. ptr2->ptr->j
Mar 19 '07 #2

Expert 100+
P: 1,510
typedef struct structure1{
int i;
int *j;
} struct_name1;

typedef struct structure2 {
int k;
struct_name1 *ptr;
} struct_name2 , *ptr2;

I need to know how to access pointer' j 'with *ptr2;
try
Expand|Select|Wrap|Line Numbers
  1.   struct_name2 s2;
  2.   ptr2 p2=&s2;
  3.   struct_name1 s1;
  4.   p2->ptr=&s1;
  5.   int i=10;
  6.   p2->ptr->j  =&i;
  7.  
Mar 19 '07 #3

Post your reply

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