English, asked by ameersohel038, 4 days ago

b) Write a C program to find the occurrence of a given word in a text file.​

Answers

Answered by aryan41997532
0
#include void main() { char a[100],b[20],c[20]; int i,count=0,k=0,len; clrscr(); printf ("\nEnter a string:-> "); gets(a); printf("\nEnter the word to be searched:-> "); gets(b); len=strlen(a); for(i=0;i<=len;i++) { //Assuming Space , Tab and NULL as word separator if(a[i]==32 || a[i]=='\t' || a[i]=='\0' { c[k]='\0' if(strcmp(b,c)==0)count++; k=0; } else { c[k]=a[i]; k++; } } printf("Occurance of %s is = %d",b,count); getch(); } Read more on Sarthaks.com - https://www.sarthaks.com/443741/write-a-c-program-that-reads-the-text-and-counts-all-occurrences-of-a-particular-word
Similar questions