C Program to Find Sub String
This is the C Program to find the substring in c,it searches the whole string to find the substring and returns the position if it founds one
#include<stdio.h>
#include<string.h>
main()
{
char string[100];
char word[100];
int i,j;
printf("Enter a String n");
gets(string);
printf("Enter a Sub-String to Searchn");
gets(word);
i=strlen(string);
j=strlen(word);
printf("The String contains %d Characters and Substring Contains %d Charactersn",i,j);
search(string,word,i,j);
}
search(char *a,char *b,int l1,int l2)
{
int j=0,i,count=0;
for(i=0;i<l1;i++)
{
while(b[j]==a[i]&&a[i]!='