answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

int main()

{

int i=0,j=0,k=0,count=0,l=0,k1=0;

char a[80],b[80];

clrscr();

printf("\nEnter main string:-\n");

gets(a);

printf("\nEnter sub-string:-\n");

gets(b);

l=strlen(b);

while (a[i]!=EOF)

{

if (a[i]==b[j])

{

i++;

j++;

k1=1;

if (j==l)

{

j=0;

k=1;

count=count+1;

}

}

else

{

if (k1==1)

{

j=0;

k1=0;

}

else

i++;

}

}

if (k==1)

{

printf("\n\nThe given sub-string is present in the main string.");

printf("\nIt is present %d times.",count);

}

else

{

if (k==0)

printf("\n\nThe given sub-string is not present in the main string.");

}

}

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

Do I need to write a program to find a substring in a given string in c plus plus?

No.


Write a Java Program to find occurences of given word in a text?

Check the documentation of the String class, for a method that searches for a substring.


What is th function of the charindex?

The CHARINDEX function in SQL is used to find the position of a specific character or substring within a string. It returns the starting position of the substring or character within the given string.


What is substr function does in c?

it will give the substring of length(as per the user) from the actual string,and the starting length from where it has to copy the substring from actual should be given by the user.


Write a java program to count the space from the given line?

.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......


How would you implement a substr function that extracts a sub string from a given string?

substr(string, position [, count]) It extract substring starting from start and going for count characters. If count is not specified, the string is clipped from the start till the end


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


Write a program to change the case of the given string?

This functionality is already in Java. String.toLowerCase() and String.toUpperCase() will take care of it for you.


How do you write a program to find the no of words in a given string in dot net?

You find a language that can be targeted towards the .NET Framework. What you are suggesting is something related to string manipulation and you can work with delimiters.


Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


Write a program in c to convert a given string to lower case?

Use the tolower() function. Example: char* a = 'X'; a = tolower(a); printf("%c", a);


A Write the algorithm to concatenate two given strings?

a write the algorithm to concatenate two given string