单链表里有三种类型元素,将它们按类型分为三个循环链表 这个算法哪里出错?

#include
#include
#include
typedef char ElemType;

typedef struct LNode{
ElemType data;
struct LNode *next;
}LNode , *LinkList , *CiList ;

void CreateList( LinkList &L ,int n )
{
LinkList p , q ;
L = ( LinkList ) malloc ( sizeof ( LNode) );
L ->next = NULL ;
q = L ;
for ( int i=0 ; i < n ; i++)
{
p = ( LinkList ) malloc ( sizeof ( LNode) );
scanf( " %c", &p->data );
p->next = q->next ;
q->next = p ;
q = p ;
}
}
void DipList ( LinkList L )
{
LinkList p = L ;
while ( p->next != NULL )
{
p = p->next ;
printf ( "%c", p->data);
printf(" ");
}
}
void Separate_List ( LinkList L , CiList &La ,CiList &Lb ,CiList &Lc )
{
LNode *p,*q,*r,*s ;
La = ( CiList ) malloc ( sizeof( LNode )); p = La ;
Lb = ( CiList ) malloc ( sizeof( LNode )); q = Lb ;
Lc = ( CiList ) malloc ( sizeof( LNode )); r = Lc ;
s = L->next ;
while ( s!= NULL )
{
if ( s->data >= '0' && s->data <= '9')
{
p->next = s ;
p = s ;
s = s->next ;
}
if( s->data >= 'a' && s->data <= 'z')
{
q->next = s ;
q = s ;
s = s->next ;
}
else
{
r->next = s ;
r = s ;
s = s->next ;
}
}
p->next = La ;
q->next = Lb ;
r->next = Lc ;
}
void main()
{
LinkList L;
CiList La , Lb ,Lc ;
int n ;
printf( "请输入单链表长度:\n");
scanf("%d",&n);
printf("请输入单链表元素:\n");
CreateList( L , n );
printf("输入的单链表为:\n");
DipList ( L ) ;
Separate_List ( L , La ,Lb ,Lc );

printf("分离后的循环链表La为:\n");
DipList ( La ) ;
printf("分离后的循环链表Lb为:\n");
DipList ( Lb ) ;
printf("分离后的循环链表Lc为:\n");
DipList ( Lc ) ;

}
到分离这个函数的时候就会出错 但是我自己检查自己的算法始终不知道错在哪 求指点 十分感谢!!

 while ( s!= NULL )

s = s->next ;

不能保证 此时s不是null

if( s->data >= 'a' && s->data <= 'z')
这里如果s是null就出错了