SUBSTRING

        

                  TO FIND SUBSTRING IN GIVEN STRING


#include<stdio.h>
#include<conio.h>
void main()
   {
       char s1[10],S3[10];int n1=0;
int i,flag;
char r[10],a[10]; int j=0;
  printf("Enter 1st string\n");
  scanf("%s",&s1);
   for(i=0;s1[i]!='\0';i++)
       n1++;
printf("Enter substring\n");
  scanf("%s",&r);
  for(i=0;i<n1;i++)
    {
     if(s1[i]==r[j])
      { a[j]=r[j];
      j++;
      }
    }
    if(a[10]==r[10])
       {
printf("substring is present\n");  }
    else
printf("substring is not present\n");
    getch();
   }


No comments:

Post a Comment

If you have any problems related to solutions or any concept please let me know.

Copyright (c) 2020 Custom Programs All Right Reserved

Pages