C初学,求教、哪里导致运行错误?
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
typedef struct wordnode{
char Eword[30];
char Chinese[100];
struct wordnode* next;
}WORDNODE;
WORDNODE* Create()
{
int i=-1,len=sizeof(WORDNODE),j,m,n;
char gwords[30][130];
WORDNODE *p1,*p2,*h;
p1=p2=h=(WORDNODE*)malloc(len);
do
{
j=0;
m=0;
i++;
gets(gwords[i]);
if(gwords[i][1]!='#'&&gwords[i][0]!='#')
{
p1=p2;
while(!isspace(gwords[i][j]))
{
p1->Eword[j]=gwords[i][j];
j=j+1;
}
p1->Eword[j]='\0';
for(n=j+1;n<(int)strlen(gwords[i]);n++)
{
p1->Chinese[m]=gwords[i][n];
m=m+1;
}
p1->Chinese[m]='\0';
p2=(WORDNODE*)malloc(len);
p1->next=p2;
}
else
{
p1->next=NULL;
free(p2);
}
}while(gwords[i][1]!='#'&&gwords[i][0]!='#');
return h;
}
void print(WORDNODE* h)
{
WORDNODE*p;
p=h;
while(p!=NULL)
{
printf("%s %s\n",p->Eword,p->Chinese);
p=p->next;
}
}
int main()
{
print(Create());
return 0;
}