刚才的程序写的有点急
效率不好
改一下:
#include<stdio.h>
long space=(5+2)*5+1+2;
char letter[29];
FILE *fp;
void OpenFile()
{
if((fp=fopen("letter26.txt","rd"))==NULL)
{
printf("You don't have the 'letter26.txt' file!");
getch();
exit(1);
}
}
char *ReadLetter(int num)
{
fseek(fp,space*num+3,0);
fread(letter,sizeof(char),29,fp);
}
main()
{
int i,j,w,l=0;
char *word;
OpenFile();
printf("Input word:");
gets(word);
system("cls");
while(word[l])
{
if(word[l]>='A'&&word[l]<='Z')
w='A';
else
if(word[l]>='a'&&word[l]<='z')
w='a';
else
{
printf("Unlawful word!");
getch();
exit(1);
}
ReadLetter(word[l]-w);
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
if(letter[j*6+i]=='*')
{
gotoxy(i+l*6+1,j+1);
printf("%c",letter[j*6+i]);
}
}
l++;
}
getch();
fclose(fp);
}