Write C Program Make Dictionary Add String File Search One Letter Print First Letter Word Q37106567

write a c program to make a dictionary …. we addstring in file and if we search with only one letter then print allits same first letter word and if we enter the complete name thenprint the only same number…..it can be done only with linkedlists…


Solution


#include<stdio.h>

int main(){

char text[100];

char myMatchedWord[100];

printf(“enter word:”);

gets(text);

int len=strlen(text);

File *fp;

char ch;

fp=fopen(‘filepat.txt’,’r’);

while(ch=(getc(fp))!=EOF)

{

if(ch==text)

{

if(len==1)

{

if((prevChar==”)||(prevChar==’ ‘)||(prevChar==’n’))

{

ch=getc(fp);

while(ch!=”||ch!=’ ‘||ch!=’n’)

{

strcat(myMatchedWord,ch);

ch=getc(fp);

}

printf(“%s”,myMatchedWord);

myMatchedWord=”;

}

}

else if((prevChar==”)||(prevChar==’ ‘)||(prevChar==’n’))

{

ch=getc(fp);

while(ch!=”||ch!=’ ‘||ch!=’n’)

{

strcat(myMatchedWord,ch);

ch=getc(fp);

}

if(myMatchedWord==text)

printf(“%s”,myMatchedWord);

myMatchedWord=”;

}

}

char prevChar=ch;

}

}

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.