Tuesday 23, May 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 : 5416
   
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 : 1619
   
pointer and there uses in c
Example code for pointer and there uses in c language....more »
Category : C Programs Hits : 1814
   
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 : 4123
   
concatenate two strings c language
Here is an example code to concatenate two strings using clanguage....more »
Category : C Programs Hits : 3170
   
   
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 Pocket Mentor Formula  Ebook Pocket Mentor Formula
   
Download Viral Marketing Secrets Ebook Viral Marketing Secrets
   
Download SEO  Search Engine Optimization Made Easy Ebook SEO Search Engine Optimization Made Easy
   
Download Powerful Webmaster Resources Ebook Powerful Webmaster Resources
   
Download Are You Ready Ebook Are You Ready
   
     
Studiesinn.com 2017 All Rights Reserved.
 
Website Designed & Developed by TechXprtz