c语言课设实验报告记事本程序含源码文档格式.docx
- 文档编号:20371137
- 上传时间:2023-01-22
- 格式:DOCX
- 页数:23
- 大小:22.20KB
c语言课设实验报告记事本程序含源码文档格式.docx
《c语言课设实验报告记事本程序含源码文档格式.docx》由会员分享,可在线阅读,更多相关《c语言课设实验报告记事本程序含源码文档格式.docx(23页珍藏版)》请在冰豆网上搜索。
所以我想由用户自己给文件命名,文件名是用一个字符串数组来存放,猜想建立文件的函数为fp=fopen("
c:
\%s.txt"
s(存放文件名的数组名),'
'
ab+"
),但运行报错,猜想不可行,于是向老师请教了这个问题,经老师指导,用指针来存放文件名,fp=(s,"
),输入文件名时得要按某盘根录下+某文件夹下+文件名的形式输入。
编到这儿,file子菜单的功能就完成了,接下来就是edit子菜单功能函数的编写。
但因为不知道key_alt_e的扫描码,在网上也搜索不到,课设老师也不太记得了,说用bioskey函数把这个值输出来,但是程序编写好后,输出的值不稳定,且不是十进制数值,于是就向其他的老师需求帮助,在老师的帮助下,知道了key_alt_e的扫描码,于是可以打开edit子菜单功能。
但在这个过程中又遇到了edit子菜单窗口的问题,通过不断改变window(),box(),gotoxy()函数中参数的数值,一次一次运行调试,查看是否到位,是否美观,最后才把把值确定。
edit子菜单中查找和替换功能要繁琐,就没编译。
程序大致也编译完成了,功能都可以实现,但是还是文件写入的问题,文件打开后,里面没有任何内容,实为系统问题,程序无任何语法错误,但程序的功能可以运行。
代码及注释:
#include<
process.h>
stdlib.h>
stdio.h>
dos.h>
conio.h>
time.h>
#definekey_down80
#definekey_up72
#definekey_esc1
#definekey_alt_f33
#definekey_alt_x45
#definekey_enter28
#definekey_alt_e18
intget_key();
voidbox(intstartx,intstary,inthigh,intwidth);
{
inti,key,x,y,l;
char*w=NULL,*d=NULL,*s=NULL;
FILE*fp;
char*menu[]={"
File"
"
Edit"
"
Format"
View"
Help"
};
char*red[]={"
F"
E"
V"
H"
char*f[]={"
New"
Open"
"
Save"
Another"
Quitalt_x"
char*e[]={"
Search"
Searchnext"
Replace"
Date"
charbuf[16*10*2],buf1[16*2];
textbackground(3);
clrscr();
window(1,1,80,1);
textbackground(WHITE);
textcolor(BLUE);
window(1,1,80,2);
for(i=0,l=0;
i<
5;
i++)
x=wherex();
y=wherey();
textcolor(BLACK);
cprintf("
%s"
menu[i]);
l=strlen(menu[i]);
gotoxy(x,y);
textcolor(RED);
%s"
red[i]);
x=x+l+4;
}
printf("
\n"
);
Youcantakeyournotenow\n"
gets(w);
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"
menu[1]);
gettext(4,2,25,8,buf);
window(12,2,25,6);
textbackground(WHITE);
clrscr();
window(12,2,25,9);
box(1,1,6,14);
for(i=2;
i<
6;
gotoxy(2,i);
%s"
e[i-2]);
}
gettext(2,2,18,3,buf1);
textbackground(0);
textcolor(15);
gotoxy(2,2);
e[0]);
y=2;
while(key!
=key_alt_e&
&
key!
=key_enter&
=key_esc)
{
if(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);
gotoxy(2,y);
e[y-2]);
}
if(key==key_alt_x)
exit(0);
if(key==key_enter)
switch(y-1)
case1:
window(1,2,80,25);
textbackground(YELLOW);
/*Search();
*/
break;
case2:
/*Search_next();
case3:
window(1,2,80,12);
/*Replace();
case4:
fp=fopen(d,"
rb+"
if(fp==NULL)
printf("
Notexist!
"
else
Inputthefiletodate;
"
scanf("
d);
Enterthetimeofreminding:
%ld"
&
t);
rewind(fp);
delay(t);
fread(w,strlen(*w),1,fp);
*w);
default:
else
window(1,1,80,2);
puttext(4,2,25,8,buf);
gotoxy(21,1);
menu[2]);
if(key==key_alt_x)
if(key==key_alt_f)
gotoxy(4,1);
menu[0]);
gettext(4,2,18,12,buf);
window(4,2,17,7);
window(4,2,20,10);
box(1,1,7,14);
7;
f[i-2]);
f[0]);
=key_alt_x&
=key_esc)
puttext(2,y,18,y+1,buf1);
6:
y=y==6?
gettext(2,y,18,y+1,buf1);
f[y-2]);
switch(y-1)
Youcantakeyournotenow:
textbackground
(2);
Pleaseinputthefileyouwanttoopen:
s);
fp=fopen(s,"
r+"
if(fp==NULL)
textbackground(BLUE);
qqq%s\n"
save(w);
Another(w);
break;
case5:
puttext(4,2,19,10,buf);
intget_key()
unionREGSrg;
rg.h.ah=0;
int86(0x16,&
rg,&
rg);
returnrg.h.ah;
}
voidbox(intstartx,intstarty,inthigh,intwidth)
inti;
gotoxy(startx,starty);
putch(0xda);
for(i=startx+1;
i<
width;
i++)
putch(0xc4);
putch(0xbf);
for(i=starty+1;
high+starty;
gotoxy(startx,i);
putch(0xb3);
gotoxy(width,i);
gotoxy(startx,starty+high-1);
putch(0xc0);
gotoxy(startx+1,starty+high-1);
for(i=startx+1;
putch(0xd9);
return;
intrenew_interface()
{
inti,key,x,y,l;
char*w=NULL;
char*d=NULL,*s=NULL;
Search"
S"
NEW"
Quitalt_x"
3;
printf("
textcolor(BLUE);
scanf("
while(bioskey
(1)==0);
case0:
/*window(1,2,80,12);
Replace();
}break;
textbackground(15);
textcolor(0);
box(1,1,8,20);
if(key=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 实验 报告 记事本 程序 源码