?? deletebynumber.c
字號:
#include "common.h"
/*********************************************************
函數名:deleteByNumber
形參:要處理的數組
返回值:刪除后的數組中的人數
函數功能:遍歷數組刪除指定的記錄
作者:xyh
編寫日期:2006-8-8
**********************************************************/
int deleteByNumber(MEMBER team[],int count){
char number[20];
// int count=0;
int flag=0;//標志是否找到
int i,delSub;
printf("請輸入要刪除員工的編號:\n");
scanf("%s",number);
//gets(number);
for(i=0;i<count;i++){//遍歷,刪除符合條件的記錄
if( !strcmp(team[i].number,number)){//符合條件
flag=1;
delSub=i;
break;
}
}
if(!flag)//沒有找到要刪除的結點
printf("\n對不起,沒有符合條件的記錄!\n\n");
else{//找到要刪除的結點
for(i=delSub;i<count-1;i++)//遍歷,找到刪除點
team[i]=team[i+1];
count--;//刪除一個隊員,總數減一;若上步驟中要刪除的下標為count-1,通過count--操作也能在邏輯上刪掉它
writeToFile(team,count);//將更新后的數組寫入文件
printf("刪除成功!以下是刪除后的結果:\n");
list(team,count);//輸出新數組
}
return count;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -