ImageVerifierCode 换一换
格式:DOCX , 页数:23 ,大小:22.20KB ,
资源ID:7264043      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7264043.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(c语言课设实验报告记事本程序含源码.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

c语言课设实验报告记事本程序含源码.docx

1、c语言课设实验报告记事本程序含源码C语言课设实验报告记事本程序班级:学号:姓名: 指导老师:2012.9.3-2012.9.24 C语言课设实验报告题目:编写一个记事本程序。设计要求:1、记录要做的事,到设定的时间后弹出对话框提醒 。2、能实现编辑、保存、另存为、查找替换等功能。3、提示:使用文件输入输出流,定时器。课设过程:拿到题目时,还没有一个大概的设计思路。当看完file,menu,graphic的程序代码之后,有了大致的代码结构:1、先做好一个菜单的界面 2、file的子菜单及其功能(新建,打开,保存,另存为,退出)的实现 3、edit子菜单(查找,替换,定时)及其功能的实现。基本框架

2、做好后,再写各个功能的函数,写好后将其插到主函数中。因为各个功能互不影响,其中还涉及到功能函数之间的嵌套,还有功能的子函数的位置。在课设过程中遇到的第一个问题是输入内容的存放。在file例子中是用结构体来存放输入内容,一开始,我想用一个字符串数组来存放,但文件内容写入的时候写入失败,文件可以建立,但打开后里面没有内容。我觉得是fwrite()函数中的各个参数有问题,fwrite括号中的参数为(w(已定义的用来存放输入内容的字符串数组名),strlen(w2000),1,fp),于是就换成了一个普通的指针来存放,但还是行不通。之所以不用像file中的结构体那样来存放数据,是因为如果用结构体,那结

3、构体中就只有一个元素,且也元素必是一个字符串数组或是指针,为了更简洁一点,就排除了用结构体这个想法。虽然输入的内容写不进所建立的文件中,但不会影响其他功能函数的编写。在写完输入,文件的建立和内容的写入函数后,接着就是输入内容的保存和另存为,这两个功能差不多,只是文件名不同。因为在创建文件程序块里文件名是程序员自己命名好了的,并且只能建立一个,每次输入的内容会把上次输入的文件内容覆盖。所以我想由用户自己给文件命名,文件名是用一个字符串数组来存放,猜想建立文件的函数为fp=fopen(c:%s.txt,s(存放文件名的数组名),ab+),但运行报错,猜想不可行,于是向老师请教了这个问题,经老师指导

4、,用指针来存放文件名,fp=(s,ab+),输入文件名时得要按某盘根录下+某文件夹下+文件名的形式输入。编到这儿,file子菜单的功能就完成了,接下来就是edit子菜单功能函数的编写。但因为不知道key_alt_e的扫描码,在网上也搜索不到,课设老师也不太记得了,说用bioskey函数把这个值输出来,但是程序编写好后,输出的值不稳定,且不是十进制数值,于是就向其他的老师需求帮助,在老师的帮助下,知道了key_alt_e的扫描码,于是可以打开edit子菜单功能。但在这个过程中又遇到了edit子菜单窗口的问题,通过不断改变window(),box(),gotoxy()函数中参数的数值,一次一次运行

5、调试,查看是否到位,是否美观,最后才把把值确定。edit子菜单中查找和替换功能要繁琐,就没编译。程序大致也编译完成了,功能都可以实现,但是还是文件写入的问题,文件打开后,里面没有任何内容,实为系统问题,程序无任何语法错误,但程序的功能可以运行。代码及注释:#include #include #include #include #include #include #define key_down 80 #define key_up 72 #define key_esc 1 #define key_alt_f 33 #define key_alt_x 45 #define key_enter 28

6、 #define key_alt_e 18int get_key();void box(int startx,int stary,int high,int width); int i,key,x,y,l; char *w=NULL,*d=NULL,*s=NULL; FILE *fp;char *menu= File , Edit ,Format,View,Help;char *red= F, E,F,V,H;char *f= New , Open , Save, Another,Quit alt_x;char *e=Search,Search next,Replace,Date;char bu

7、f16*10*2,buf116*2;textbackground(3);clrscr(); window(1,1,80,1);textbackground(WHITE);textcolor(BLUE);clrscr(); window(1,1,80,2);for(i=0, l=0; i 5;i+) x=wherex(); y=wherey(); textcolor(BLACK); cprintf( %s ,menui); l=strlen(menui); gotoxy(x,y); textcolor(RED); cprintf( %s,redi); x=x+l+4; gotoxy(x,y);

8、printf(n);printf(You can take your note nown);gets(w);printf(kkk%s,w);while(1) key=0; while(bioskey(1)=0) key=get_key(); if(key=key_alt_e) textbackground(BLACK); textcolor(WHITE); gotoxy(12,1); cprintf(%s,menu1); gettext(4,2,25,8,buf); window(12,2,25,6); textbackground(WHITE); textcolor(BLACK); clrs

9、cr(); window(12,2,25,9); box(1,1,6,14); for(i=2;i6;i+) gotoxy(2,i); cprintf( %s ,ei-2); gettext(2,2,18,3,buf1); textbackground(0); textcolor(15); gotoxy(2,2); cprintf( %s ,e0); y=2; key=get_key(); while(key!=key_alt_e&key!=key_enter&key!=key_esc) if(key=key_up|key=key_down) puttext(2,y,32,y+1,buf1);

10、 if(key=key_up) y=y=2? 5:y-1; if(key=key_down) y=y=5? 2:y+1; gettext(2,y,32,y+1,buf1); textbackground(0); textcolor(15); gotoxy(2,y); cprintf( %s ,ey-2); key=get_key(); if(key=key_alt_x) exit(0); if(key=key_enter) switch(y-1) case 1: window(1,2,80,25); textbackground(YELLOW); clrscr(); /* Search();

11、*/ break; case 2: window(1,2,80,25); textbackground(YELLOW); clrscr(); /* Search_next(); */ break; case 3: window(1,2,80,12); textbackground(YELLOW); clrscr(); /* Replace(); */ break; case 4: window(1,2,80,25); textbackground(YELLOW); clrscr(); fp=fopen(d,rb+); if(fp=NULL) printf(Not exist!); else p

12、rintf(Input the file to date; ); scanf(%s,d); fp=fopen(d,rb+); if(fp=NULL) printf(Not exist!); else printf(Enter the time of reminding:); scanf(%ld,&t); rewind(fp); delay(t); fread(w,strlen(*w),1,fp); printf(%s,*w); break; default: break; else window(1,1,80,2); puttext(4,2,25,8,buf); textbackground(

13、WHITE); textcolor(BLACK); gotoxy(21,1); cprintf( %s ,menu2); if(key=key_alt_x) exit(0); if(key=key_alt_f) textbackground(BLACK); textcolor(WHITE); gotoxy(4,1); cprintf( %s ,menu0); gettext(4,2,18,12,buf); window(4,2,17,7); textbackground(WHITE); textcolor(BLACK); clrscr(); window(4,2,20,10); box(1,1

14、,7,14); for(i=2; i 7;i+) gotoxy(2,i); cprintf( %s ,fi-2); gettext(2,2,18,3,buf1); textbackground(0); textcolor(15); gotoxy(2,2); cprintf( %s ,f0); y=2; key=get_key(); while(key!=key_alt_x&key!=key_enter&key!=key_esc) if(key=key_up|key=key_down) puttext(2,y,18,y+1,buf1); if(key=key_up) y=y=2? 6:y-1;

15、if(key=key_down) y=y=6? 2:y+1; gettext(2,y,18,y+1,buf1); textbackground(0); textcolor(15); gotoxy(2,y); cprintf( %s ,fy-2); key=get_key(); if(key=key_alt_x) exit(0); if(key=key_enter) switch(y-1) case 1: window(1,2,80,25); textbackground(YELLOW); clrscr(); printf(You can take your note now:n); scanf

16、(%s,w); break; case 2: window(1,2,80,25); textbackground(2); clrscr(); printf(Please input the file you want to open :); scanf(%s,s); fp=fopen(s,r+); if(fp=NULL) printf(Not exist!); else rewind(fp); fread(w,strlen(*w),1,fp); printf(%s,*w); break; case 3: window(1,2,80,25); textbackground(BLUE); clrs

17、cr(); printf(qqq%sn,w); save(w); break; case 4: window(1,2,80,25); textbackground(BLUE); clrscr(); Another(w);break; case 5: exit(0); default: break; else window(1,1,80,2); puttext(4,2,19,10,buf); textbackground(WHITE); textcolor(BLACK); gotoxy(4,1); cprintf( %s ,menu0); int get_key() union REGS rg;

18、 rg.h.ah=0; int86(0x16,&rg,&rg); return rg.h.ah; void box(int startx,int starty,int high,int width) int i; gotoxy(startx,starty); putch(0xda); for (i=startx+1;i width;i+) putch(0xc4); putch(0xbf); for(i=starty+1;i high+starty;i+) gotoxy(startx,i); putch(0xb3); gotoxy(width,i); putch(0xb3); gotoxy(st

19、artx,starty+high-1); putch(0xc0); gotoxy(startx+1,starty+high-1); for(i=startx+1;i width;i+) putch(0xc4); putch(0xd9); return; int renew_interface() int i,key,x,y,l; char *w=NULL; char *d=NULL,*s=NULL; FILE *fp;char *menu= File , Edit , Search ;char *red= F, E, S;char *f= NEW , Open , Save, Another,

20、Quit alt_x ;char *e=Search,Search next,Replace,Date;char buf16*10*2,buf116*2;textbackground(3);clrscr(); window(1,1,80,1);textbackground(WHITE);textcolor(BLUE);clrscr(); window(1,1,80,2);for(i=0, l=0; i 3;i+) x=wherex(); y=wherey(); printf( %s ,menui); l=strlen(menui); gotoxy(x,y); textcolor(BLUE);

21、cprintf( %s ,redi); x=x+l+4; gotoxy(x,y); textcolor(BLACK); printf(n);printf(You can take your note now:n);scanf(%s,w);while(1) key=0; while (bioskey(1)=0); key=get_key(); if(key=key_alt_e) textbackground(BLACK); textcolor(WHITE); gotoxy(12,1); cprintf(%s,menu1); gettext(4,2,25,8,buf); window(12,2,2

22、5,6); textbackground(WHITE); textcolor(BLACK); clrscr(); window(12,2,25,9); box(1,1,6,14); for(i=2;i6;i+) gotoxy(2,i); cprintf( %s ,ei-2); gettext(2,2,18,3,buf1); textbackground(0); textcolor(15); gotoxy(2,2); cprintf( %s ,e0); y=2; key=get_key(); while(key!=key_alt_e&key!=key_enter&key!=key_esc) if

23、(key=key_up|key=key_down) puttext(2,y,32,y+1,buf1); if(key=key_up) y=y=2? 5:y-1; if(key=key_down) y=y=5? 2:y+1; gettext(2,y,32,y+1,buf1); textbackground(0); textcolor(15); gotoxy(2,y); cprintf( %s ,ey-2); key=get_key(); if(key=key_alt_x) exit(0); if(key=key_enter) switch(y-1) case 0: window(1,2,80,2

24、5); textbackground(YELLOW); clrscr(); /* Search(); */ break; case 1: window(1,2,80,25); textbackground(YELLOW); clrscr(); /* Search_next(); */ break; case 2: /* window(1,2,80,12); textbackground(YELLOW); clrscr(); Replace(); */ break; case 3: window(1,2,80,25); textbackground(YELLOW); clrscr(); fp=f

25、open(d,rb+); if(fp=NULL) printf(Not exist!); else printf(Input the file to date; ); scanf(%s,d); fp=fopen(d,rb+); if(fp=NULL) printf(Not exist!); else printf(Enter the time of reminding:); scanf(%ld,&t); rewind(fp); delay(t); fread(w,strlen(*w),1,fp); printf(%s,*w); break; default: break; else windo

26、w(1,1,80,2); puttext(4,2,25,8,buf); textbackground(WHITE); textcolor(BLACK); gotoxy(21,1); cprintf( %s ,menu2); if(key=key_alt_x) exit(0); if(key=key_alt_f) textbackground(0); textcolor(15); gotoxy(4,1); cprintf( %s ,menu0); gettext(4,2,18,12,buf); window(4,2,20,10); textbackground(15); textcolor(0)

27、; clrscr(); window(4,2,20,10); box(1,1,8,20); for(i=2; i 7;i+) gotoxy(2,i); printf( %s ,fi-2); gettext(2,2,18,3,buf1); textbackground(2); textcolor(15); gotoxy(2,2); cprintf( %s ,f0); y=2; key=get_key(); while(key!=key_alt_x&key!=key_enter&key!=key_esc) if(key=key_up|key=key_down) puttext(2,y,18,y+1,buf1); if(key=key_up) y=y=2? 6:y-1; if(key=key_down) y=y=6? 2:y+1; gettext(2,y,18,y+1,buf1); textbackground(0); textcolor(15); gotoxy(2,y); cprintf( %s ,fy-2); key=get_key(); if(key=key_alt_x) exit(0); if(key=

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1