How do I correct this code? I'm getting an error message telling me that local function definitions are illegal.
It also says "end of file found before left brace." What's that?
Code:
node * pop (node * head)
{ node* p=NULL;
node* q =NULL;
cout<<"Enter value to be deleted: ";
cin>>num;
//cout<<"** Error Empty Stack **"<<endl;
if (head->n==num)
{
p = head;
head=head->next;
delete p;
}
else
{
p = head; // point to the 1st node which is going to be removed
q=head->next;
while (q!=NULL && q->n<num)
{
p=q;
q=q->next;
}
if (q->n==num)
{
p->next =q->next;
delete q;
}
else if (q==NULL || q->n>num)
cout<<"** Error Value not found **"<<endl;
}
return head;
}
void print(node * head)
{
node * p=NULL;
if (head==NULL)
cout<<"** Error Empty Stack **"<<endl;
else
{
p = head;
while (p!=NULL)
{
cout<<p->n<<" ";
p=p->next;
}
}
return;
}