-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path12.c
More file actions
38 lines (27 loc) · 737 Bytes
/
Copy path12.c
File metadata and controls
38 lines (27 loc) · 737 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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main()
{
int i, j, counter = 0;
int start, length, text_len;
char text[10000], word[100], temp[10000];
printf("Enter a Text : ");
gets(text);
text_len = strlen(text);
printf("Enter Sub-string to Find Occurrences : ");
gets(word);
for (i = 0; i < text_len; i++)
{
if (text[i] == word[0])
{
for (j = 0; j < text_len - i; j++)
temp[j] = text[i + j];
}
if (strstr(temp, word) != NULL)
counter++;
}
printf("Total Occurrence of \" %s \" in text : %d times\n", word, counter);
return 0;
}