Friday 20, April 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
 
C program to join two strings without using strcat
This c language program will join two strings without using strcat string function....more »
Category : C Programs Hits : 2258
   
Convert decimal number to binary number in c
This c language program will input an integer in decimal numbers system and convert it to binary numbers system. Decimal to Binary Conversion, Convert from decimal to binary using c language....more »
Category : C Programs Hits : 4663
   
Check the given year is leap or not using c
This program will input a year and check whether it is a leap year or not....more »
Category : C Programs Hits : 3520
   
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 : 1828
   
Bubble sort using c language
This program will sort an array using bubble sort in c language. c program for bubble sort, bubble sort in c, sorting an array using bubble sort in c language....more »
Category : C Programs Hits : 3765
   
   
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 Create Your First Website By 345 This Afternoon  Ebook Create Your First Website By 345 This Afternoon
   
Download Dotcomology Ebook Dotcomology
   
Download Producing Open Source Software: How to Run a Successful Free Software Project  Ebook Producing Open Source Software: How to Run a Successful Free Software Project
   
Download The Secret to Winning Ebook The Secret to Winning
   
Download Enhance Your Financial Intelligence Ebook Enhance Your Financial Intelligence
   
Studiesinn.com 2018 All Rights Reserved.