⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 基于VC的小型数据库管理程序源代码
💻 CPP
字号:
#include "include.h"

char operationselect;  //操作选择
extern Inflinklist *head;
int main(void)
{
     char cn;  //标记是否继续进行	
	 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); //清空缓冲区,避免多输入时对后面的影响

	 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 + -