S
Sameer
Hello Group,
This is one problem in programming that is troubling me.
there is a segmentation fault just before creating memory to
a structure ..i.e, just after the "allocating memory " statement.
This happens for some inputs and not all.
What can be the reason for such fault ?
Kindly reply soon,
Sameer.
void add(struct node **q)
{
struct node *temp;
temp=*q;
if(*q==NULL)
{
*q=new node;
temp=*q;
}
else
{
cout << "allocating memory";
temp = new node;
cout << "memory allocated";
temp->next=*q;
}
}
This is one problem in programming that is troubling me.
there is a segmentation fault just before creating memory to
a structure ..i.e, just after the "allocating memory " statement.
This happens for some inputs and not all.
What can be the reason for such fault ?
Kindly reply soon,
Sameer.
void add(struct node **q)
{
struct node *temp;
temp=*q;
if(*q==NULL)
{
*q=new node;
temp=*q;
}
else
{
cout << "allocating memory";
temp = new node;
cout << "memory allocated";
temp->next=*q;
}
}