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

structures help

P: 63
Expand|Select|Wrap|Line Numbers
  1. typedef struct subStruct {
  2. int value;
  3. }SubStruct;
  4.  
  5. typedef struct mainStruct {
  6. SubStruct sarray[10];
  7. int val;
  8. }MainStruct;
  9.  
  10. int main () {
  11. MainStruct* pMainStruct;
  12. pMainStruct->sarray[1].value=10;
  13.  
  14. printf(" value is %d",pMainStruct->sarray[1].value);
  15. return 0;
  16.  
  17. }
the value is geting printed ....the program has no errors ....but
insteead some exception is shown
May 24 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 181
typedef struct subStruct {
int value;
}SubStruct;

typedef struct mainStruct {
SubStruct sarray[10];
int val;
}MainStruct;

int main () {
MainStruct* pMainStruct;
pMainStruct->sarray[1].value=10;

printf(" value is %d",pMainStruct->sarray[1].value);
return 0;

}

the value is geting printed ....the program has no errors ....but
insteead some exception is shown
you have to intialize pMainStruct with valid address.
May 24 '07 #2

P: 63
thanks ,...
solved now...
May 24 '07 #3

Post your reply

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