标题:指针插入哪里有问题???
只看楼主
少林小和尚
Rank: 2
等 级:论坛游民
帖 子:57
专家分:26
注 册:2013-3-31
结帖率:73.68%
 问题点数:0 回复次数:0 
指针插入哪里有问题???
void insert(struct staff *head)
     {
         int flag;
            struct staff *insert,*temp1,*temp2;
           printf("请按-1退出该操作\n");
lab: flag=0;      
                                                   //继续添加标志
           printf("姓名  性别  职位  地址  年龄  电话  工作时间  月工资\n");
           scanf("%s  %s  %s  %s  %d  %ld  %d  %d",insert->name,insert->sex,insert->position,insert->adress,&insert->age,&insert->phone,&insert->working_time,&insert->month_wages);
           temp2=head;
           temp1=head->next;
          if(strcmp(insert->name,"-1")==0)
              return ;
          while(temp1!=NULL)
          {
              if(strcmp(insert->name,temp1->name)<0)       //如果小于0 就插入
              {
                  temp2->next=insert;
                  insert->next=temp1;
                  printf("插入成功\n");
                   goto lab;
              }
               else
               {
                   temp2=temp1;
                   temp1=temp1->next;
               }  
          }
          if(temp1==NULL)
          {
               temp1->next=insert;
               insert->next=NULL;
          }
          goto lab;
搜索更多相关主题的帖子: position insert 电话 姓名 职位 
2013-06-23 18:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-415874-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.101013 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved