#include <stdio.h>
#include <string.h>

#define SIZE 300

int main(void)
{
    char text[SIZE];
    char searchString[SIZE];

    int totalOccurrences = 0;

    printf("Enter a line of text:\n");
    fgets(text, SIZE, stdin);

    printf("Enter the search string:\n");
    fgets(searchString, SIZE, stdin);

    text[strcspn(text, "\n")] = '\0';
    searchString[strcspn(searchString, "\n")] = '\0';

    char *searchPtr = text;

    while ((searchPtr =
            strstr(searchPtr, searchString)) != NULL)
    {
        ++totalOccurrences;

        searchPtr += 1;
    }

    printf("\nThe search string occurred %d times.\n",
           totalOccurrences);

    return 0;
}