struct node
{
vector<int> v;
};
//case 1:
struct node *t = (struct node *) malloc(sizeof(struct node));
t->v.push_back(4);// segmentation fault
//case 2:
struct node t;
t.v.push_back(6);
I know the reason of segmentation fault in first case we have dynamically allocated memory . then we are trying to use the memory which is not allocated. In second case we are using stack memory. can you explain it more clearly ? sry for bad style of asking doubt , i am newbie