【正文】
rior=ptr2。 printf(\nInserting success!Cotinue to insert?(yes or no):)。 gotoxy(20,10)。 gotoxy(16,12)。}/*刪除模塊*/COM *delet( ) {char name[10]。 clrscr( )。 head=openfile( )。 gotoxy(3,4)。 printf( * depend on goodsnumber\n)。 printf(please choose a number between 1 and 2:)。 gotoxy(6,6)。 break。 scanf(%s,amp。amp。 printf(Success to delect goodsmessage!\n)。amp。} if(ptr1num==del_num||(strcmp(ptr1name,name)==0)) {ptr2next=ptr1next。 } else printf(\nCan39。 }while(!strcmp(judge,yes))。 gotoxy(18,11)。 getch( )。 int sel。 printf(Please press searched goods39。 else do {do {clrscr( )。 printf( * depend on goodsnumber\n)。 scanf(%d,amp。 scanf(%ld,amp。 printf(Please input goodsname:)。amp。amp。 if ((ptr1num==sel_num)||(strcmp(ptr1name,name)==0)) {printf(\n Success to search goodsmessage!\n)。t find this goodsmessage!\n\n)。 gotoxy(10,24)。 clrscr( )。 head=openfile( )。 printf(goodsnumber goodsname goodscount\n\n)。 if(i/10==1) /*超過(guò)十行換頁(yè)*/ {i=0。 gotoxy(0,6)。 gotoxy(10,24)。 gotoxy(8,13)。 if((fp=fopen(strcat(filename1,filename2),wb))==NULL) /*以二進(jìn)制只寫(xiě)方式打開(kāi)一個(gè)流*/ {printf(Fail to creat FILE!)。 while(ptr1!=NULL) {if(fwrite(ptr1,sizeof(COM),1,fp)!=1) {printf(Fail to print message to FILE!)。 } fclose(fp)。}/*載入模塊*/COM * openfile( ){int n=1。t exist,please check if exist.\npress any key back to Menu)。 getch( )。 return(NULL)。 n=n+1。return(NULL)。 } }while(ptr1next!=NULL)。} /*關(guān)閉文件函數(shù)*/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 you \n can search message depend on the goodsnub or goodsname. \n\n\n *Wele to enter the GOODS SYSTEM!* \n }。textbackground(LIGHTGRAY)。printf(%s,message)。do{clrscr( )。printf(please choose a number from 0 to 6:)。 /*輸入模塊*/ break。 /*插入模塊*/ break。 /*查找模塊*/ break。}}while(sel!=0)。 /*保存模塊*/ break。 /*刪除模塊*/ break。 /*輸出模塊*/ break。sel)。printf(%s,menu)。printf( Please press any key into the Menu!)。 /*背景為銀灰色,字為藍(lán)色*/clrscr( )。int sel。 }return(head)。 getch( )。 if((ptr1=(COM*)malloc(LEN))==NULL) {printf(No enough memory,fail to creat linklist!\nPlease press any key to back to Menu\n)。 else { do {if(n==1) head=ptr1。 } if(fread(ptr1,sizeof(COM),1,fp)!=1) /*從fp指向的流中讀取1個(gè)字段,每個(gè)字段為COM的字符長(zhǎng),并把它們放到ptr1指向的字符數(shù)組中,文件的位置指示器隨著所讀取的字符數(shù)而下移*/ {printf(Fail to print message from FILE!\nPlease press any key back to Menu\n)。 return(NULL)。 if((fp=fopen(strcat(filename1,filename2),rb))==NULL) {gotoxy(15,13)。 printf(Saving success!Press any key to back to last Menu:)。 return。 return。filename(limit to letter or number):)。 getch( )。 } i=i+1。 getch( )。 do {printf(PRINT)。 else clrscr( )。 printf(Please input printed goods39。 getch( )。 scanf(%s,judge)。