-
Notifications
You must be signed in to change notification settings - Fork 0
/
isSubString.c
44 lines (36 loc) · 812 Bytes
/
isSubString.c
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
41
42
43
44
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
char smallstr[100], bigstr[200];
char *p;
int position, i=0;
printf("Enter bigger string\n");
scanf(" %[^\n]s", bigstr);
printf("Enter smaller string\n");
scanf(" %[^\n]s", smallstr);
printf("Big string after transformation to lowercase is:-\n");
while(bigstr[i])
{
putchar(tolower(bigstr[i]) );
i++;
}
printf("\nsmall string after transformation to lowercase is:-\n");
i=0;
while(smallstr[i])
{
putchar(tolower(smallstr[i]) );
i++;
}
printf("\n");
p = strstr(bigstr,smallstr);
if (p==0)
printf(" '%s' is not contained in '%s' \n", smallstr,bigstr);
else
{
position = (int)(p-bigstr);
printf(" '%s' is contained in '%s' starting from the position %d \n", smallstr,bigstr, position);
}
return 0;
}