资源描述:
《实验三linux_c_程序设计》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《Linux程序开发环境》实验报告实验成绩:批阅教师:年月日实验3LinuxC程序设计1、实验目的(1)掌握Linuxshell程序运行方法(2)掌握LinuxShell程序基本语法(3)了解Linux环境变量(4)编写简单Linuxshell程序2、实验内容使用curses库完成CD唱片管理系统的C语言简单用户界面版。实验步骤见附录。3、实验记录(1)实验报告中提交系统的完整脚本;#include#include#include#include#include<
2、curses.h>#defineMAX_STRING(80)/*Longestallowedresponse*/#defineMAX_ENTRY(1024)/*Longestalloweddatabaseentry*/#defineMESSAGE_LINE6/*Misc.messagesgohere*/#defineERROR_LINE22/*Thelinetouseforerrors*/#defineQ_LINE20/*LineforQuestions*/#definePROMPT_LINE18/*Lineforpromptingon*/
3、staticcharcurrent_cd[MAX_STRING]=" ";staticcharcurrent_cat[MAX_STRING];constchar*title_file="title.cdb";constchar*tracks_file="tracks.cdb";constchar*temp_file="cdb.tmp";/*Prototypesforlocalfunctions*/voidclear_all_screen(void);voidget_return(void);intget_confirm(void);int
4、getchoice(char*greet,char*choices[]);voiddraw_menu(char*options[],inthighlight,intstart_row,intstart_col);voidinsert_title(char*cdtitle);voidget_string(char*string);voidadd_record(void);voidcount_cds(void);voidfind_cd(void);voidlist_tracks(void);voidremove_tracks(void);voi
5、dremove_cd(void);voidupdate_cd(void);/*菜单项*/char*main_menu[]={"aaddnewCD","ffindCD","ccountCDsandtracksinthecatalog","qquit",0,};/*TheextendedmenuisdisplayedwhenaCDiscurrentlyselected*/char*extended_menu[]={"aaddnewCD","ffindCD","ccountCDsandtracksinthecatalog","llisttrack
6、soncurrentCD","rremovecurrentCD","uupdatetrackinformation","qquit",0,};intmain(){intchoice;initscr();do{choice=getchoice("Options:",current_cd[0]?extended_menu:main_menu);switch(choice){case'q':break;case'a':add_record();break;case'c':count_cds();break;case'f':find_cd();br
7、eak;case'l':list_tracks();break;case'r':remove_cd();break;case'u':update_cd();break;}}while(choice!='q');endwin();exit(EXIT_SUCCESS);}/*main*///addmenu/*getchoice-asktheusertochoosepassed:greet,anintroductionchoices,anarrayofstrings,NULLatend*/intgetchoice(char*greet,char*
8、choices[]){staticintselected_row=0;intmax_row=0;intstart_screenrow=MESSAGE_LINE,start_scr