Advertisement
bappy7706

Keyword detection

Feb 18th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.  
  6.     char str[1000],ab[1000];
  7.     printf("Enter a string: ");
  8.     scanf("%[^\n]%*c",str);
  9.     int i,p,q=0;
  10.  
  11.     for(i=0; str[i]!='\0' ; i++)
  12.     {
  13.         if(str[i]=='f')
  14.         {
  15.             p=i;
  16.             if(str[p+1]=='o' && str[p+2]=='r' && str[p+3]==' ' )
  17.             {
  18.                 ab[q]=str[i];
  19.                 q++;
  20.                 ab[q]=str[p+1];
  21.                 q++;
  22.                 ab[q]=str[p+2];
  23.                 q++;
  24.                 ab[q]=' ';
  25.                 q++;
  26.             }
  27.  
  28.         }
  29.         else if(str[i]=='w')
  30.         {
  31.             p=i;
  32.             if(str[p+1]=='h' && str[p+2]=='i' && str[p+3]=='l' && str[p+4]=='e' && str[p+5]==' ')
  33.             {
  34.                 ab[q]=str[i];
  35.                 q++;
  36.                 ab[q]=str[p+1];
  37.                 q++;
  38.                 ab[q]=str[p+2];
  39.                 q++;
  40.                 ab[q]=str[p+3];
  41.                 q++;
  42.                 ab[q]=str[p+4];
  43.                 q++;
  44.                 ab[q]=' ';
  45.                 q++;
  46.             }
  47.         }
  48.  
  49.     }
  50.     ab[q]='\0';
  51.  
  52.     printf("\nKeywords are: ");
  53.     for(i=0; ab[i]!='\0'; i++)
  54.     {
  55.         printf("%c",ab[i]);
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement