帮我修改下我的程序
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#include<graphics.h>
#include<bios.h>
#include<dos.h>
#define STARTX 10
#define STARTY 5
#define SIZE 17
void main()
{ void initGraph();
int lenth,i;
char test[2000],c;
FILE *fp;
if((fp=fopen("d:\\tc\\a1\\tesk.txt","r"))==NULL)
{ printf("can not open\n");
getch();
exit(1);
}
i=0;
while(!feof(fp))
{ fscanf(fp,"%c",&c);
if(c>31)
test[lenth=i++]=c;
}
fclose(fp);
initGraph();
cleardevice();
setbkcolor(BLACK);
sittesk(lenth,test);
dotesk(lenth,test);
closegraph();
getch();
}
int row,col;
draw(int i,int j,char key,int color)
{ int x,y;
char keys[2];
keys[1]='\0';
keys[0]=key;
x=STARTX+j*SIZE;
y=STARTY+i*SIZE;
settextjustify(1,1);
settextstyle(1,0,1);
setcolor(color);
outtextxy(x,y,keys);
}
sittesk(int lenth,char *test)
{ int i;
for(i=0;i<lenth;i++)
{ row=i/(630/SIZE);
col=i%(630/SIZE);
draw(2*row,col,test[i],LIGHTGREEN);
}
}
dotesk(int lenth,char *test)
{ int key,i,error=0;
double x,y;
char word,c;
char complete[30],right[30];
for(i=0;i<lenth;i++)
{ row=i/(630/SIZE);
col=i%(630/SIZE);
key=bioskey(0);
word=key%256;
if(word==test[i])
draw(2*row+1,col,test[i],WHITE);
else { draw(2*row+1,col,word,RED);
printf("%c",7);
error++;
}
if(key/256==1)
break;
}
sprintf(complete,"Completion is %5.2f %",i*100.00/lenth);
sprintf(right,"Exactitude is %5.2f %",(i-error)*100.00/lenth);
setcolor(BROWN);
settextjustify(1,1);
settextstyle(3,0,2);
outtextxy(450,430,complete);
outtextxy(450,450,right);
getch();
exit(1);
}
void initGraph()
{ int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"d:\\tc");
errorcode=graphresult();
if(errorcode!=grOk)
{ printf("Graphics error:%s\n",grapherrormsg(errorcode));
exit(0);
}
}