Monday 20, February 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 number is prime or not using c

Here is a code example to check the number is prime or not a prime number. It will input number from user. If number is prime, it will print "Number is prime" on screen and if number is not prime it will print "Number is not prime".

...more »
Category : C Programs Hits : 5360
   
arrays and pointers in c
An example code for arrays and pointers in c language....more »
Category : C Programs Hits : 1743
   
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 : 3020
   
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 : 1613
   
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 : 2872
   
   
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 Practical PHP Programming  Ebook Practical PHP Programming
   
Download How to Avoid Success at all costs Ebook How to Avoid Success at all costs
   
Download The Affiliate Marketers Companion  Ebook The Affiliate Marketers Companion
   
Download The Top 10 Ways to Speed Up Your Windows PC Right Now  For Free Ebook The Top 10 Ways to Speed Up Your Windows PC Right Now For Free
   
Download Biz Opp Of The Decade Ebook Biz Opp Of The Decade
   
     
Studiesinn.com 2017 All Rights Reserved.
 
Website Designed & Developed by TechXprtz