forked from Vishal-Aggarwal0305/DSA-CODE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindSubString.c
More file actions
40 lines (39 loc) · 776 Bytes
/
FindSubString.c
File metadata and controls
40 lines (39 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h>
#include<string.h>
int check(char[],char[],int);
int main()
{
char a[100],b[100];
int x=0,i=0;
gets(a); // input of main string
gets(b); //input of substring
for(i=0;i<strlen(a);i++)
{
if(a[i]==b[0])
{
x=check(a,b,i);
if(x)
{
printf("found at : %d location ",i);
}
}
}
}
int check(char a[],char b[],int x)
{
int j=0,flag=1;
while(b[j]!='\0') //check b is end or not
{
if(a[x]!=b[j])
{
flag=0;
break;
}
j++;
x++;
}
if (flag==1)
return 1;
else
return 0;
}