C language check whether the string contains substrings

www.lautt‮moc.iru‬
C language check whether the string contains substrings

Check if the substring is in another string:

/*
Example check if a string contains a substring in C language
*/

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

int main(int argc, char *argv[]) {
    char s1[] = "hello lautturi world,lautturi.com";
    char s2[] = "lautturi";
    char* p;

	// check whether a substring is in another string:
    // Find the location where it first appeared
    p = strstr(s1, s2);

    if (p) {
        printf("\"lautturi\" found in string\n");
        printf("First occurrence position :%s", p);
    } else
        printf("\"lautturi\" not found in string\n");
}
Created Time:2017-08-28 12:07:39  Author:lautturi