请教一个c语言的数据结构与算法的单链表中的删除问题
#include <stdio.h>
#include <stdlib.h>
struct Node{
int data;
struct Node * next;
};
typedef struct Node pNode;
typedef struct Node *LinkList;
void delete_node(struct Node * h,int x);
void main(void)
{
// LinkList p;
pNode a,b,c;
a.data = 1; a.next = &b;
b.data = 2; b.next = &c;
c.data = 3; c.next = NULL;
delete_node(&a, 2);
/* p = &a;
while(p)
{
printf("%d ",p->data);
}*/
}
void delete_node(struct Node * h,int x)
{
struct Node *p,*q;
q=h;p=h->next;
if(p!=NULL)
{
while ((p!=NULL)&&(p->data!=x))
{
q=p;p=p->next;
}
if(p->data =x)
{
q->next=p->next;free(p);
}
}
}
运行没错,但是没结果!!!