user-0 提问: 判断是否ESC按下，是则return pHead；不知道是检测不出按键还是其他错误，就是退不出子函数

回复:
user: user-1
content: 2楼代码不行，应改为： pStu create_stu(void) {     pStu pHead=NULL, pNew=NULL;     int i,len=0,k;     char s[256];      pHead = (pStu)malloc(sizeof(Stu));     if(NULL == pHead) {         printf ("创建失败!\n");         exit(-1);     }      pStu pTail = pHead;     pTail->pNext = NULL;       printf("请按顺序输入学生的\n学号\t姓名\t分数(语,数,英)\t性别\t年龄\t籍贯\n");      for(i=0; i< STU_NUM; i++) {         pNew = (pStu)malloc(sizeof(Stu));         if(NULL == pNew) {             printf ("创建失败!\n");             exit(-1);         }         while (1) {             if (_kbhit()) {                 k=_getch();                 if (0==k||0xe0==k) getch();//功能键             } else break;         }         printf ("请输入第%d个学生的信息（按Esc键退出!）:\n", i+1);          k=_getche();         if (0==k||0xe0==k) {getch();k=0;}//功能键         if (27==k) return pHead;         if (k>0) {             s[0]=k;             fgets(s+1,255,stdin);         } else {             fgets(s  ,256,stdin);         }          if (2!=sscanf(s,"%d%s",   &pNew->iNumber, &pNew->cName))                         {printf("格式错误!\n"); return pHead;}         if (3!=scanf("%d%d%d", &pNew->iGrade[0], &pNew->iGrade[1], &pNew->iGrade[2])) {printf("格式错误!\n"); return pHead;}         if (1!=scanf("%s",     &pNew->cSex))                                          {printf("格式错误!\n"); return pHead;}         if (1!=scanf("%d",     &pNew->iAge))                                          {printf("格式错误!\n"); return pHead;}         if (1!=scanf("%s",     &pNew->cAdress))                                       {printf("格式错误!\n"); return pHead;}           pTail->pNext = pNew;         pNew->pNext = NULL;         pTail = pNew;     } }

user: user-1
content: pStu create_stu(void) {     pStu pHead=NULL, pNew=NULL;     int i,len=0,k;      pHead = (pStu)malloc(sizeof(Stu));     if(NULL == pHead) {         printf ("创建失败!\n");         exit(-1);     }      pStu pTail = pHead;     pTail->pNext = NULL;       printf("请按顺序输入学生的\n学号\t姓名\t分数(语,数,英)\t性别\t年龄\t籍贯\n");      for(i=0; i< STU_NUM; i++) {         pNew = (pStu)malloc(sizeof(Stu));         if(NULL == pNew) {             printf ("创建失败!\n");             exit(-1);         }         while (1) {             if (_kbhit()) {                 k=_getch();                 if (0==k||0xe0==k) getch();             } else break;         }         printf ("请输入第%d个学生的信息（按Esc键退出!）:\n", i+1);          k=_getch();         if (0==k||0xe0==k) {getch();k=0;}         if (27==k) return pHead;         if (k>0) _ungetch(k);          if (2!=scanf("%d%s",   &pNew->iNumber, &pNew->cName))                         {printf("格式错误!\n"); return pHead;}         if (3!=scanf("%d%d%d", &pNew->iGrade[0], &pNew->iGrade[1], &pNew->iGrade[2])) {printf("格式错误!\n"); return pHead;}         if (1!=scanf("%s",     &pNew->cSex))                                          {printf("格式错误!\n"); return pHead;}         if (1!=scanf("%d",     &pNew->iAge))                                          {printf("格式错误!\n"); return pHead;}         if (1!=scanf("%s",     &pNew->cAdress))                                       {printf("格式错误!\n"); return pHead;}          pTail->pNext = pNew;         pNew->pNext = NULL;         pTail = pNew;     } }

user: user-0
content: 顶了，请大家帮忙看看！怎么改？？？

user: user-0
content: 恩恩  谢啦，已经解决了！！！我这个函数写的没错，只是在调用它的函数中少写了一行代码，然后再写错两行代码的顺序。结构害我折腾一上午！！！现在已经好了，谢啦！！！