毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 课程设计 >> 正文

C语言仓库管理系统-数据结构 第5页

更新时间:2010-1-25:  来源:毕业论文
C语言仓库管理系统-数据结构 第5页
/*保存模块*/
void save(COM *head)
{ clrscr();
  gotoxy(8,13);
  printf("Please input saved goods'filename(limit to letter or number):");
  scanf("%s",filename1);
  if((fp=fopen(strcat(filename1,filename2),"wb"))==NULL)    /*以二进制只写方式打开一个流*/
   {printf("Fail to creat FILE!");
    getch( );
    return;
   }
  ptr1=ptr2=head;
  while(ptr1!=NULL)
  {if(fwrite(ptr1,sizeof(COM),1,fp)!=1)
    {printf("Fail to print message to FILE!");
     getch( );
     return;
   }
  ptr1=ptr1->next;
  }
  fclose(fp);
  gotoxy(10,24);
  printf("Saving success!Press any key to back to last Menu:");
  getch();
}
/*载入模块*/
COM * openfile( )
{int n=1;
 scanf("%s",filename1);
 if((fp=fopen(strcat(filename1,filename2),"rb"))==NULL)
 {gotoxy(15,13);
  printf("This filename isn't exist,please check if exist.\npress any key back to Menu");
  getch( );
  return(NULL);
  }
 if((ptr1=ptr2=(COM*)malloc(LEN))==NULL)
 {printf("No enough memory,fail to creat linklist!\nPlease press any key back to Menu\n");
 getch( );
 return(NULL);
 }
 if(fread(ptr1,sizeof(COM),1,fp)!=1)            /*从fp指向的流中读取1个字段,每个字段为COM的字符长,并把它们放到ptr1指向的字符数组中,文件的位置指示器随着所读取的字符数而下移*/
  {printf("Fail to print message from FILE!\nPlease press any key back to Menu\n");
   getch( );
   return(NULL);
   }
 if(ptr1->next==NULL)
  head=ptr1;
 else
 { do
  {if(n==1)
   head=ptr1;
  else ptr2->next=ptr1;
  n=n+1;
  ptr2=ptr1;
  if((ptr1=(COM*)malloc(LEN))==NULL)
   {printf("No enough memory,fail to creat linklist!\nPlease press any key to back to Menu\n");
   getch( );return(NULL);
    }
  if(fread(ptr1,sizeof(COM),1,fp)!=1)
  {printf("Fail to print message from FILE!\nPlease press any key to back to Menu\n");
  getch( );return(NULL);
  }
  }while(ptr1->next!=NULL);
   ptr2->next=ptr1;
 }
return(head);
fclose(fp);}            /*关闭文件函数*/
void main( )
{char message[ ]={"        ----*The instruction of GOODS SYSTEM*-----            \n\n"
                  "    You can input many kinds of messages,and you can use         \n"
                  "    goodname as FILEname                                 \n"
                  "    This SYSTEM can do operation like insert or delect to the     \n"
                  "    goodsmessage that have saved,then saved again.while you       \n"
                  "    can search message depend on the goodsnub or goodsname.  \n\n\n"
                  "      ---*Welcome to enter the GOODS SYSTEM!*---         \n"
               };
char menu[ ]={"      ******************MENU********************          \n\n\n"
       "                       *1.Input                                \n"
       "                       *2.Output                               \n"
       "                       *3.Insert                               \n"
       "                       *4.Delete                               \n"
       "                       *5.Search                               \n"
       "                       *6.Save                                 \n"
www.751com.cn
textbackground(LIGHTGRAY);
textcolor(BLUE);                               /*背景为银灰色,字为蓝色*/
clrscr( );
gotoxy(4,8);
printf("%s",message);
gotoxy(10,22);
printf("        Please press any key into the Menu!");
getch( );
do
{clrscr( );
gotoxy(1,7);
printf("%s",menu);
gotoxy(10,20);
printf("please choose a number from 0 to 6:");
scanf("%d",&sel);
switch(sel)
{case 1:head=input( );                 /*输入模块*/
        break;                       
 case 2:print( );                      /*输出模块*/
        break;
 case 3:head=insert( );                /*插入模块*/
        break;
 case 4:head=delet( );                /*删除模块*/
        break;
 case 5:search( );                     /*查找模块*/
        break;
 case 6:save(head);                   /*保存模块*/
        break;
 case 0:break;}
}while(sel!=0);
}

上一页  [1] [2] [3] [4] [5] [6] 下一页

C语言仓库管理系统-数据结构 第5页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。