|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#define SIZE 30
struct noname{
char nowfilled[SIZE];
int count;
};
typedef struct noname Item;
typedef struct node
{
Item item;
struct node* next;
}Node;
typedef Node * List;
List head, pre, current;
List buildchain(void)
{
char willfilled[SIZE];
head = NULL;
puts("请输入第一个节点:\n");
while (s_gets(willfilled, SIZE) != NULL && willfilled[0] != '\0') //变动部分
{
current = (List)malloc(sizeof(List));
if (current == NULL);
puts("stop\n"); //测试时打印了stop
current->item.count++;
if (head = NULL)
head = current;
else
pre->next = current;
current->next = NULL;
strcpy(current->item.nowfilled, willfilled); //变动部分
eatline();
puts("请输入下一个节点(或输入空行取消):\n");
pre = current;
}
return head;
}
int main(void)
{
List now;
now = buildchain( );
}
current = (List)malloc(sizeof(Node)); 我不太清除为什么要用两次转定义,你可以直接在结构体创建的时间,将List加在后面就行了,指针也是可以的··
|
|