c++ - segment fault when assigning a new allocated memory to a struct pointer -


struct student { public:     string name;     string family;     string stdno;     string ncode;     float average;     float age;     struct student *fl; } *start, *cur, *p;  p = new struct student;     cur->fl = p;     p->fl = null; // p->fl = nullptr in c++11     cur = p; 

i try assigning new memory allocated structure pointer,it seems there no issue segment fault when cur->fl = p; ran, doing wrong here ?

cur has not been assigned point to

cur = p;

needs before p->fl


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -