Tried to trace, but did not find a reason why the following code is giving "Access violation" in VC++, and segmentation fault in gcc..
#include <vector>
#include <iostream>
using namespace std;
typedef struct node
{
    std::string data;
    vector <struct node*> child;
}NODE, *PNODE;
int main()
{
    PNODE head;
    head = (PNODE) malloc(sizeof(NODE));
    head->data.assign("hi");
    printf("data %s", head->data.c_str());
    getchar();
}
 
     
     
     
     
    