| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 642 人关注过本帖
标题:各位朋友支援一下小弟,看看这个程序错了那些地方。。。拜谢!
只看楼主 加入收藏
2Ⅰ℃→咖啡
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-6-20
收藏
 问题点数:0 回复次数:3 
各位朋友支援一下小弟,看看这个程序错了那些地方。。。拜谢!

请大虾们帮我指正一下!!拜谢 # include "graphics.h" # include "stdio.h" # include "fcntl.h" # include "stdlib.h" main()

void save(),load(); void *wg,*rg,*vg,*fy; int driver,mode; int c=RED; int x=320,y=225; int x1,y1,x2,y2; int k,k1,k2; /* initialize grapher */ detectgraph(&driver,&mode); initgraph(&driver,&mode,"c:\tc");

/* write the pen */ bar(200,10,206,16); line(203,7,200,10); line(203,7,206,10); line(243,7,240,16); line(243,7,246,16); line(283,7,280,10); line(283,7,286,10); line(283,7,283,16);

/* save the pen */ wg=malloc(imagesize(200,7,206,16)); rg=malloc(imagesize(240,7,246,16)); vg=malloc(imagesize(280,7,286,16)); fy=malloc(imagesize(200,7,206,16));

getimage(200,7,206,16,wg); getimage(240,7,246,16,rg); getimage(280,7,286,16,vg); cleardevice();

/* write the box */ setcolor(YELLOW); rectangle(4,19,637,447);

x1=x-3; y1=y+1; x2=x+3; y2=y+10; getimage(x1,y1,x2,y2,fy); putimage(x1,y1,vg,XOR_PUT);

/* receive the command */ for (;;) while (bioskey(1)==0); k=bioskey(0); putimage(x1,y1,fy,AND_PUT); if (((k&0x00ff)|0x00)==0) k1=k&0xff?0:k>>8; /* k1 is the specialkey value */ else k2=k&0x00ff; /* k2 is the non-specialkey value */ if (((k&0x00ff)|0x00)==0) /* Special key */ switch(k1) case 45: restorecrtmode(); exit(0); case 72: if (y>20) y=y-1; break; case 75: if (x>5) x=x-1; break; case 77: if (x<636) x=x+1; break; case 80: if (y<446) y=y+1; break; case 71: if ((x>5)&&(y>20)) x=x-1; y=y-1; break; case 79: if ((x>5)&&(y<446)) x=x-1; y=y+1; break; case 73: if ((x<636)&&(y>20)) x=x+1; y=y-1; break; case 81: if ((x<636)&&(y<446)) x=x+1; y=y+1; break;

x1=x-3; y1=y+1; x2=x+3; y2=y+10; getimage(x1,y1,x2,y2,fy); /* non-special key */ switch(k2) case 118: /* 'v' */ case 86: /* 'V' */ putimage(x1,y1,vg,OR_PUT); break; case 119: /* 'w' */ case 87: /* 'W' */ putimage(x1,y1,wg,OR_PUT); putpixel(x,y,c); break; case 114: /* 'r' */ case 82: /* 'R' */ putimage(x1,y1,rg,OR_PUT); putpixel(x,y,BLACK); break; case 115: /* 's' */ case 83: /* 'S' */ save("pic.dat"); break; case 101: /* 'e' */ case 69: /* 'E' */ load("pic.dat"); break; case 99: /*'c'*/ case 67: /*'C'*/ setcolor(RED); circle(x,y,20); break; default:continue;

/* function for screen picture save */ void save(char *fname)

FILE *fp; int i; register long j; char far *ptr;

fp=fopen(fname,"wb"); for(i=0;i<4;i++)

outportb(0x3CE,4); outportb(0x3CF,i); ptr=(char far *) 0xA0000000L; for (j=0;j<38400L;j++) putc(*ptr,fp); ptr++;

fclose(fp); outportb(0x3CF,0);

/* function for screen picture display */ void load(char *fname)

FILE *fp; register int i; int k4=1; register long j; char far *ptr;

fp=fopen(fname,"rb"); for (i=0;i<4;i++)

outportb(0x3C4,2); outportb(0x3C5,k4); ptr=(char far *)0xA0000000L; for (j=0;j<38400L;j++)

*ptr=getc(fp); ptr++;

k4*=2;

fclose(fp); outportb(0x3C5,0xF);

搜索更多相关主题的帖子: 朋友 支援 拜谢 
2005-06-20 18:43
2Ⅰ℃→咖啡
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-6-20
收藏
得分:0 
我知道这个有点多,但是还是恳请各位赐教
2005-06-20 20:12
tary
Rank: 1
等 级:新手上路
帖 子:780
专家分:0
注 册:2004-10-5
收藏
得分:0 

偶对楼主写程序的习惯只有一个字来形容,汗..

void save(),load();这是两个子函数吧..可你根本就没有跟main分开.. 你怎么连{}这个都忘了.

还有你这个程序还有其它的文件,没有弄上来.. 偶帮你改了下.. 可以运行,不过,, 效果不出现,,偶也没认真去阅读你的程序..

或者你该说说你这个程序到底干什么用的.

# include "graphics.h" # include "stdio.h" # include "fcntl.h" # include "stdlib.h" main() { void save(),load(); void *wg,*rg,*vg,*fy; int driver=DETECT,mode; int c=RED; int x=320,y=225; int x1,y1,x2,y2; int k,k1,k2; /* initialize grapher */ initgraph(&driver,&mode,"c:\tc");

/* write the pen */ bar(200,10,206,16); line(203,7,200,10); line(203,7,206,10); line(243,7,240,16); line(243,7,246,16); line(283,7,280,10); line(283,7,286,10); line(283,7,283,16);

/* save the pen */ wg=malloc(imagesize(200,7,206,16)); rg=malloc(imagesize(240,7,246,16)); vg=malloc(imagesize(280,7,286,16)); fy=malloc(imagesize(200,7,206,16));

getimage(200,7,206,16,wg); getimage(240,7,246,16,rg); getimage(280,7,286,16,vg); cleardevice();

/* write the box */ setcolor(YELLOW); rectangle(4,19,637,447);

x1=x-3; y1=y+1; x2=x+3; y2=y+10; getimage(x1,y1,x2,y2,fy); putimage(x1,y1,vg,XOR_PUT);

/* receive the command */ for (;;) while (bioskey(1)==0); k=bioskey(0); putimage(x1,y1,fy,AND_PUT); if (((k&0x00ff)|0x00)==0) k1=k&0xff?0:k>>8; /* k1 is the specialkey value */ else k2=k&0x00ff; /* k2 is the non-specialkey value */ if (((k&0x00ff)|0x00)==0) /* Special key */ switch(k1) { case 45: restorecrtmode(); exit(0); case 72: if (y>20) y=y-1; break; case 75: if (x>5) x=x-1; break; case 77: if (x<636) x=x+1; break; case 80: if (y<446) y=y+1; break; case 71: if ((x>5)&&(y>20)) x=x-1; y=y-1; break; case 79: if ((x>5)&&(y<446)) x=x-1; y=y+1; break; case 73: if ((x<636)&&(y>20)) x=x+1; y=y-1; break; case 81: if ((x<636)&&(y<446)) x=x+1; y=y+1; break;

x1=x-3; y1=y+1; x2=x+3; y2=y+10; getimage(x1,y1,x2,y2,fy); } /* non-special key */ switch(k2) { case 118: /* 'v' */ case 86: /* 'V' */ putimage(x1,y1,vg,OR_PUT); break; case 119: /* 'w' */ case 87: /* 'W' */ putimage(x1,y1,wg,OR_PUT); putpixel(x,y,c); break; case 114: /* 'r' */ case 82: /* 'R' */ putimage(x1,y1,rg,OR_PUT); putpixel(x,y,BLACK); break; case 115: /* 's' */ case 83: /* 'S' */ save("pic.dat"); break; case 101: /* 'e' */ case 69: /* 'E' */ load("pic.dat"); break; case 99: /*'c'*/ case 67: /*'C'*/ setcolor(RED); circle(x,y,20); break; default: break; } } /* function for screen picture save */ void save(char *fname) { FILE *fp; int i; register long j; char far *ptr;

fp=fopen(fname,"wb"); for(i=0;i<4;i++)

outportb(0x3CE,4); outportb(0x3CF,i); ptr=(char far *) 0xA0000000L; for (j=0;j<38400L;j++) putc(*ptr,fp); ptr++;

fclose(fp); outportb(0x3CF,0); }

/* function for screen picture display */ void load(char *fname) { FILE *fp; register int i; int k4=1; register long j; char far *ptr;

fp=fopen(fname,"rb"); for (i=0;i<4;i++)

outportb(0x3C4,2); outportb(0x3C5,k4); ptr=(char far *)0xA0000000L; for (j=0;j<38400L;j++)

*ptr=getc(fp); ptr++;

k4*=2;

fclose(fp); outportb(0x3C5,0xF);}


┌→¨ ≮我可以学会对你很冷落≯¨←┐ │  <却学不╓══╦══╖会将爱> │ │¨←┐ ╭╩╮哭‖哭╭╩╮ ┌→¨│ └──┘收 ╲╱ ◇‖◇ ╲╱回└──┘
2005-06-20 21:38
2Ⅰ℃→咖啡
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-6-20
收藏
得分:0 
是电工图的设计,呵,我很菜,确实做不好~!多谢赐教!!临表泣。。。
2005-06-21 13:47
快速回复:各位朋友支援一下小弟,看看这个程序错了那些地方。。。拜谢!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022275 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved