/**/ /* 练习使用链表:创建链表、遍历链表、查找节点、添加节点、删除节点*/ #include " stdio.h " #include " string.h " #include " assert.h " #include " stdlib.h " #include " windows.h " #define COUNT 3 // 定义一个节点结构体 struct NODE ... { unsigned long uID; char strName[16]; //用指针的话会出访问冲突异常 NODE *next;} ; // 创建一个具有n个节点的链表,从键盘输入数据将其初始化,并返回链表的首节点指针 NODE * createNode( int n) ... { NODE *pHead, //首节点指针 *pRear, //尾节点指针 *pNew; //新节点指针 int i; char *strName = new char[16]; for (i=0; i<n; i++) ...{ pNew = new NODE; do ...{ printf("请输入ID和名称: "); scanf("%d %s",&pNew->uID, strName); if (strlen(strName) > 16) ...{ printf("输入名称长度超出范围,请重新输入: "); Sleep(1000);