Friday 20, July 2018
Welcome Guest, Register | Login  
      Home       Tutorials       Free Ebooks       Free Scripts       Tech News       Articles       About Us       Blog        Forum

  Find a substring in another string using c

This program will input a string and a substring and than check whether the substring is present is string or not.
Cut & Paste Script
#include<stdio.h>
#include<conio.h>
void main()
{
    char str[80],search[10];   
    int count1=0,count2=0,i,j,flag;
   
    clrscr();
    puts("Enter a string:");
    gets(str);
    puts("Enter search substring:");
    gets(search);
    while (str[count1]!='\0')
        count1++;
    while (search[count2]!='\0')
        count2++;
    for(i=0;i<=count1-count2;i++)
    {
        for(j=i;j<i+count2;j++)
        {
            flag=1;
            if (str[j]!=search[j-i])
            {
                flag=0;
               break;
            }
        }
        if (flag==1)
            break;
    }
    if (flag==1)
        puts("Substring found");
    else
        puts("Substring not found");
    getch();
}
   
     RELATED SCRIPTS
 
arrays and pointers in c
An example code for arrays and pointers in c language....more »
Category : C Programs Hits : 2022
   
Print fibonacci series using c language
Here is a c language program which will take number of terms as input from user and prints the fibonacci series using c language loops....more »
Category : C Programs Hits : 3685
   
Find Factorials using Recursion in c
This c program will use recursive function and calculate the factorial of given number....more »
Category : C Programs Hits : 1881
   
C Program to Reverse an array
Here is a program which will take input from user in array and will reverse it using c language....more »
Category : C Programs Hits : 1947
   
pointer and there uses in c
Example code for pointer and there uses in c language....more »
Category : C Programs Hits : 1988
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download Guide To Cashing In On Ebay Ebook Guide To Cashing In On Ebay
   
Download Beginners Guide to Internet Business  Ebook Beginners Guide to Internet Business
   
Download Online Videos Become Internets Most Valuable Player Ebook Online Videos Become Internets Most Valuable Player
   
Download Niche Marketing Research In Plain English Ebook Niche Marketing Research In Plain English
   
Download All I Ever Needed to Know About Network Marketing, I Learned in Elementary Schoo Ebook All I Ever Needed to Know About Network Marketing, I Learned in Elementary Schoo
   
Studiesinn.com 2018 All Rights Reserved.