资源描述:
《3901120604-金初阳-实验三linux c 程序设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、《Linux程序开发环境》实验报告项目名称LinuxC程序设计专业班级1206班学号3901120604姓名金初阳实验成绩:批阅教师:年月日实验3LinuxC程序设计1、实验目的(1)掌握Linuxshell程序运行方法(2)掌握LinuxShell程序基本语法(3)了解Linux环境变量(4)编写简单Linuxshell程序2、实验内容使用curses库完成CD唱片管理系统的C语言简单用户界面版。实验步骤见附录。3、实验记录(1)实验报告中提交系统的完整脚本;#include#inclu
2、de#include#include#include#defineMAX_STRING(80)/*Longestallowedresponse*/#defineMAX_ENTRY(1024)/*Longestalloweddatabaseentry*/#defineMESSAGE_LINE6/*Misc.messagesgohere*/#defineERROR_LINE22/*Thelinetouseforerrors*/#defi
3、neQ_LINE20/*LineforQuestions*/#definePROMPT_LINE18/*Lineforpromptingon*/staticcharcurrent_cd[MAX_STRING]=" ";staticcharcurrent_cat[MAX_STRING];constchar*title_file="title.cdb";constchar*tracks_file="tracks.cdb";constchar*temp_file="cdb.tmp";/*Prototypesfor
4、localfunctions*/voidclear_all_screen(void);voidget_return(void);intget_confirm(void);intgetchoice(char*greet,char*choices[]);voiddraw_menu(char*options[],inthighlight,intstart_row,intstart_col);voidinsert_title(char*cdtitle);voidget_string(char*string);void
5、add_record(void);voidcount_cds(void);voidfind_cd(void);voidlist_tracks(void);voidremove_tracks(void);voidremove_cd(void);voidupdate_cd(void);/*菜单项*/char*main_menu[]={"aaddnewCD","ffindCD","ccountCDsandtracksinthecatalog","qquit",0,};/*Theextendedmenuisdispl
6、ayedwhenaCDiscurrentlyselected*/char*extended_menu[]={"aaddnewCD","ffindCD","ccountCDsandtracksinthecatalog","llisttracksoncurrentCD","rremovecurrentCD","uupdatetrackinformation","qquit",0,};intmain(){intchoice;initscr();do{choice=getchoice("Options:",curre
7、nt_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();break;case'l':list_tracks();break;case'r':remove_cd();break;case'u':update_cd();break;}}while(choice!='q');endwin();exit(EX
8、IT_SUCCESS);}/*main*///addmenu/*getchoice-asktheusertochoosepassed:greet,anintroductionchoices,anarrayofstrings,NULLatend*/intgetchoice(char*greet,char*choices[]){staticintselected_row=0;intmax_row=0;i