?? main.cpp
字號:
#include "include.h"
char operationselect; //操作選擇
extern Inflinklist *head;
int main(void)
{
char cn; //標記是否繼續(xù)進行
char name[MAX_INPUT]; //查詢姓名
fileshow(); //fileoperation中定義
Infnotice(); //otheroperation中定義
//以下是對選擇輸入操作的容錯處理
loop1: operationselect = getchar();
while(getchar()!=10) //輸入的不止是一個字符
{
fflush(stdin);
printf(" ERROR!輸入字符太多!請輸入單個字符!\t opreation:");
goto loop1;
}
while(operationselect!='I' && operationselect!='i' && operationselect!='D' && operationselect!='d'
&& operationselect!='S' && operationselect!='s' && operationselect!='X' && operationselect!='x')
{
printf("\nkey input invalid!please input again!\toperation:");
fflush( stdin );
goto loop1;
}
head=(Inflinklist *)malloc(sizeof(Inflinklist));
if (NULL == head)
{
printf("Memory is not enough! Application failed!");
exit (1);
}
head->next=NULL;
fflush(stdin); //清空緩沖區(qū),避免多輸入時對后面的影響
while(operationselect) //菜單式選擇
{
if (operationselect=='x' || operationselect=='X') //結束
break;
else
{
switch(operationselect)
{
case 'I': //輸入,大小寫不分
case 'i':
printf("輸入操作:\n");
cn = Infinput(head);
while(cn=='Y' || cn=='y')
cn = Infinput(head);
break;
case 'D': //刪除
case 'd':
printf("刪除操作:\n");
printf("Input the name to delete:");
scanf("%s",name);
cn =Infindelete(head, name);
while(cn=='Y' || cn=='y')
{
printf("\nInput the name to delete:");
scanf("%s",name);
cn = Infindelete(head, name);
}
break;
case 'S': //查詢
case 's':
printf("信息查詢:\n");
printf("Input the name to search:");
scanf("%s",name);
cn = Infsearch(head, name);
while(cn=='Y' || cn=='y')
{
printf("\nInput the name to search:");
scanf("%s",name);
cn=Infsearch(head, name);
}
break;
default:
break;
} //end switch
} //end else
Infnotice();
fflush(stdin); //清除緩沖
//以下是對選擇輸入操作的容錯處理
loop2: operationselect = getchar();
while(getchar()!=10) //輸入的不止是一個字符
{
fflush(stdin);
printf(" ERROR!輸入字符太多!請輸入單個字符!\t opreation:");
goto loop2;
}
while(operationselect!='I' && operationselect!='i' && operationselect!='D' && operationselect!='d'
&& operationselect!='S' && operationselect!='s' && operationselect!='X' && operationselect!='x')
{
printf("\nkey input invalid!please input again!\toperation:");
fflush( stdin );
goto loop2;
}
fflush(stdin);
} //end while
Infsavetxt(head); //存檔
freelinklist(head); //釋放內存
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -