Click here to Skip to main content
15,891,847 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
typedef struct {
int a;
int c;
}s1;

typedef struct {
int b;
}s2;

typedef const struct {
s1 *ptr1;
s2 *ptr2;
}M;
static M stinstance;
void main()
{
stinstance.ptr1->a = 10;
printf("%x",stinstance.ptr1);
}
Posted
Updated 7-Apr-15 19:26pm
v2

1 solution

Because the members ptr1 and ptr2 of M are pointers, that haven't been initialised - so they currently contain random values

pointers are addresses to things - those things need to be allocated, or already existing, before their address can be used

A Beginner's Guide to Pointers[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900