user-0 提问: 关于数据结构有点小问题。为什么编译器显示没有错误，而执行是总出现程序终止，这都是那种错误呢？

回复:
user: user-1
content: 关于尾链 /* *	尾插法建立链表并进行排序（大到小），倒置； */  linklist tail_createlist(linklist list,int * n){ 	list = (linklist)malloc(sizeof(listnode));//头结点分配空间 	//变量声明 	linklist p,r;	//r为尾指针 	r =list = NULL;	 	datatype  ch; 	while ((ch = getchar()) != '\n'){ 		p = (linklist)malloc(sizeof(listnode)); 		++ *n; 		p->data = ch; 		r->next = p; 		r = p; 	} 	r->next = NULL; 	return (list); } 这个函数的这句话 r =list = NULL;	 改成： 	r = list; 	list = NULL;

user: user-1
content: main函数这样改。 int main() { 	linklist LIST = NULL; 	LIST = head_createlist(LIST); 	print(LIST); 	return 0; }

user: user-0
content: /* *	尾插法建立链表并进行排序（大到小），倒置； */ #include <stdio.h> #include <stdlib.h> typedef char datatype ; //节点的描述 typedef struct node { 	datatype data;		//数据域 	struct node *next;	//指针域 }listnode,*linklist; linklist tail_createlist(linklist list,int * n);	//函数声明 linklist print(linklist list,int n); linklist sort(linklist list,int n); linklist invertion(linklist list,int n ); main(void) { 	int count ;	//节点数 	count = 0; 	linklist LIST; 	LIST = NULL; 	LIST = tail_createlist(LIST,&count);//这样要返回值，因为指针作为函数参数无法改变指针的指向，必须用返回值了 	print(LIST,count); 	LIST = sort(LIST,count); 	print(LIST,count); 	LIST = invertion(LIST,count); 	printf("\n"); 	return 0; } linklist tail_createlist(linklist list,int * n){ 	list = (linklist)malloc(sizeof(listnode));//头结点分配空间 	//变量声明 	linklist p,r;	//r为尾指针 	r =list = NULL; 	datatype  ch; 	while ((ch = getchar()) != '\n'){ 		p = (linklist)malloc(sizeof(listnode)); 		++ *n; 		p->data = ch; 		r->next = p; 		r = p; 	} 		r->next = NULL; 		return (list); } linklist print(linklist list,int n){ 	while (list->next != NULL){ 		printf("%c",list->next->data); 		list = list->next; 	} 	printf("\n"); 	printf("%d\n",n); 	return 0 ; } linklist sort(linklist list,int n){ 	//用冒泡法做一个循环 	linklist sign; 	sign = list; 	int i , j  ; 	datatype exchange; 	 	for(i = 1;i<= n;i++){ 		list = sign; 		for(j = 1;j<= n-i;j++){	 			if((list->next->data) < (list->next->next->data)){ 				exchange = list->next->next->data; 				list->next->next->data = list->next->data; 				list->next->data = exchange; 			} 			list = list->next; 		} 	} 	 	return (list); } linklist invertion(linklist list,int n){ 	int i , j; 	linklist sign; 	sign = list; 	for(i = 1;i <= n; i++){ 		list = sign; 		for(j = 1; j <= n - i;j++){ 			list = list->next; 		} 		printf("%c",list->next->data); 			 	} 	return (list); } 麻烦看些这个哪里错了呢？

user: user-2
content: #include <stdio.h> #include <stdlib.h> typedef char datatype ; //节点的描述 typedef struct node{ 	datatype data;	 //数据域 	struct node *next;	//指针域 }Node; Node* head_createlist();	//函数声明 void print(Node* list); main(void) { 	Node *list; 	list = head_createlist(); 	print(list); 	return 0; } 	Node *head_createlist() 	{ 		Node *p, *list; 		Node *head; 		datatype  ch; 		list = (Node*)malloc(sizeof(Node));//头结点分配空间 	//变量声明 		head = list; 		while ((ch=getchar()) != '\n') 		{ 			p = (Node*)malloc(sizeof(Node)); 			p->data = ch; 			head->next = p; 			head = p; 		} 		head->next = NULL; 		return list; } void print(Node* list) { 	Node *p; 	p = list->next; 	while (p) 	{ 		printf("%c\n",p->data); 		p = p->next; 	} 	 }稍微改了下，你看看

user: user-2
content: 声明要放在函数块的头部