You are on page 1of 5

SOURCE CODE:

-----------------------

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
FILE *f;
int choice,i,j,c,b,flag,st,v=0,co=0;
char ch,ip[20],op[20];
int ft[26][26]={
{0,1,1,1,1,1,1,0,1,0,0,1,1,1,0,1,1,1,1,1,1,1,1,1,0,0},
{1,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0},
{1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0},
{1,0,1,1,0,1,1,0,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0},
{1,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,0,1,0},
{1,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,1,0,0,0,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0},
{0,0,1,1,0,0,1,0,0,0,0,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0},
{1,0,0,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0},
{1,1,1,1,0,1,0,0,0,0,0,1,1,1,0,1,0,1,1,1,1,1,0,1,0,0},
{1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,1,0,1,0,0,0,1,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0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0,0,0,1,0,1,0,0,0,0,0},
{1,0,0,0,1,0,0,1,1,0,1,1,0,1,1,0,0,1,1,0,1,0,0,0,1,0},
{1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,0,1,0},
{1,1,0,0,1,0,0,0,1,0,0,1,1,1,1,1,0,0,1,0,1,0,0,0,1,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,1,0,1,1,0,0,1,0,1,1,1,0,1,1,1,1,0,0,0,1,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,0},
{1,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,1,1,1,0,1,0,1,0},
{1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1},
{1,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,1,0,1,1,0,0,1,0},
{1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,0,0,1,1,1,1,0,0,1,1,0},
{1,0,1,0,1,1,0,1,1,0,0,1,0,1,1,1,0,0,0,1,1,0,0,0,1,0},
{1,0,0,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,0,1},
{1,0,0,0,1,0,1,0,1,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,1}};
clrscr();
printf("1 for enter a word in ditionary\n2 for view the words of dictionary\n3 for
spell checking\n");
do
{
printf("\n\nenter ur choice:-");
scanf("%d",&choice);
switch(choice)
{
case 1:f=fopen("sourav.txt","a");
printf("enter the words seperated by line change:-");
while((c=getchar())!=EOF)
putc(c,f);
fclose(f);
break;
case 2:f=fopen("sourav.txt","r");
while((b=getc(f))!=EOF)
printf("%c",b);
fclose(f);
break;
case 3:f=fopen("sourav.txt","r");
printf("\nEnter the word to be checked:-");
scanf("%s",&ip);
strlwr(ip);
do
{
i=0;
while(((b=getc(f))!=10) && (b!=EOF))
{
op[i++]=(char)b;
}
op[i]='\0';
strlwr(op);
if(strcmp(ip,op)==0)
{
printf("\n Word is already in dictionary");
j=0;
break;
}
}while(b!=EOF);
fclose(f);
if(j!=0)
{
if(ip[0]>=97 && ip[0]<=122)
{
if(strlen(ip)>=3)
{
i=0;
while(ip[i]!='\0')
{
st=ip[i++];
if(st==97||st==101||st==105||st==111||st==117)
v++;
else
co++;
}
if(v==0||co==0)
flag=0;
else
{
i=0; v=1;co=1;
while(ip[i]!='\0')
{
st=ip[i++];
if(st==97||st==101||st==105||st==111||st==117)
{
if(v!=3)
{
v++;
co=1;
}
else
break;
}
else
{
if(co!=4)
{
co++;
v=1;
}
else
break;
}
}
if(v==3||co==4)
flag=0;
else
{
if(ft[ip[0]-97][ip[1]-97]==1)
{
i=2;
while(ip[i]!='\0')
{
if(sc[ip[i-1]-97][ip[i]-97]==0)
{
flag=0;
break;
}
i++;
}
flag=1;
}
else
flag=0;
}
}
}
else
flag=0;
}
else
flag=0;
if(flag!=0)
{
f=fopen("ravi.txt","a");
i=0;
while(ip[i]!='\0')
{
putc(ip[i],f);
i++;
}
putc(10,f);
fclose(f);
printf("valid word and entered into dictionary.");
}
else
printf("invalid word");
}
break;
default:printf("\ninvalid choice");
}
printf("\ndo u want to continue:y/n?\n");
fflush(stdin);
scanf("%c",&ch);

}while(ch=='y'||ch=='Y');

END

You might also like