Basic Programs
If Else based Programs
Loop Based Programs
Array Based Programs
String Programs
Function Programs
Pointers Programs
Structure & File Handling Programs
Data Structure Programs
String based programs
C program to check substring in the given string
#include<conio.h>
#include<stdio.h>
void main()
{
int i=0,j=0;
char str[50],substr[50];
printf("Enter the string : ");
gets(str);
printf("Enter substring : ");
gets(substr);
while(str[i]!='\0' && substr[j]!='\0')
{
if(str[i]!=substr[j])
{
i++;
j=0;
}
else
{
j++;
i++;
}
}
if(substr[j]=='\0')
printf("substring Found");
else
printf("Not found");
} Output of the above program is as following.
Video/ C Introduction
Watch video in full size

Enquiry about Course