为什么程序(二分查找)无法运行?

#include
#include
#define MAXSIZE 100

typedef int ElementType;
typedef int Position;
typedef struct LNode *List;
struct LNode{
ElementType Data[MAXSIZE];
Position Last;
};

Position BS(List L, ElementType x, Position Left, Position Right)
{
if (Left>Right) return -1;

int mid;
mid=(Left + Right)/2;
if(L->Data[mid] > x)
    return BS(L, x, Left, mid-1);
else if(L->Data[mid] < x)
    return BS(L, x, mid+1, Right);
else if (L->Data[mid] == x)
    return  mid;

}

Position BinarySearch(List L, ElementType X)
{
return BS(L, X, 1, L->Last);
}

int main()
{
struct LNode *L;
int i=1, x;
L=malloc(sizeof(struct LNode));
L->Last=1;

do{
    scanf("%d", L->Data[i]);
    i++;
    L->Last++;
}while(L->Data[i]!='\n');

scanf("%d",&x);
printf("%d",BinarySearch(L, x));

return 0;

}

main函数中,L=malloc(sizeof(struct LNode));改为
L=(List)malloc(sizeof(struct LNode));