Friday 23, June 2017
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    About Us    |    Contact Us

  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
 
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 : 3122
   
Compare two strings using c
This program will input two strings and compare them. It will show both strings are equal, first string is greater than second or first string is less than second....more »
Category : C Programs Hits : 1492
   
C program to show memory address of array elements and access array elements using pointers
This program will visualize the memory address of each array element and will show you how to access array elements using pointer....more »
Category : C Programs Hits : 2967
   
pointer and there uses in c
Example code for pointer and there uses in c language....more »
Category : C Programs Hits : 1829
   
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 : 3323
   
   
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 Algorithmic Problem Solving Ebook Algorithmic Problem Solving
   
Download Back to Basics Making the Most of Affiliate Marketing  Ebook Back to Basics Making the Most of Affiliate Marketing
   
Download Targeted Cyber Attacks  The Dangers Faced by your Corporate Network Ebook Targeted Cyber Attacks The Dangers Faced by your Corporate Network
   
Download An Insiders Guide To Writing Articles Ebook An Insiders Guide To Writing Articles
   
Download Forex Trading For Beginner Ebook Forex Trading For Beginner
   
     
Studiesinn.com 2017 All Rights Reserved.
 
Website Designed & Developed by TechXprtz