头插法建立单链表
#include <iostream>
using namespace std;
typedef char datatype;
typedef struct node
{
datatype data;
// struct
node *next;
} listnode;
typedef listnode * linklist; // linklist 是 listnode * 类型
listnode *p;
listnode * createlist( )
{
char ch;
linklist head; // 相当于listnode *head;
listnode *p;
head=NULL; /*初始化为空*/
ch=getchar( );
while (ch!='\n')
{
p=new listnode;
p->data=ch; /*数据域赋值*/